Skip to content

Commit

Permalink
dart_ndk: 0.1.0-dev6
Browse files Browse the repository at this point in the history
  • Loading branch information
Fmar committed Dec 19, 2023
1 parent de729c8 commit 2c7a8cd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
62 changes: 28 additions & 34 deletions android/app/src/main/kotlin/yana/nostr/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
package yana.nostr

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
import fr.acinq.secp256k1.Secp256k1
import androidx.annotation.NonNull
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

// class MainActivity: FlutterActivity() {
class MainActivity : FlutterFragmentActivity() {
private val CHANNEL = "flutter.native/helper"
//import io.flutter.embedding.android.FlutterFragmentActivity

private val secp256k1 = Secp256k1.get()
class MainActivity: FlutterActivity() {
//class MainActivity : FlutterFragmentActivity() {
// private val CHANNEL = "flutter.native/helper"

@ExperimentalStdlibApi
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine);
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
CHANNEL
).setMethodCallHandler { call, result ->
when {
call.method.equals("verifySignature") -> {
verifySignature(call, result)
}
}
}
}
fun verifySignature(
call: MethodCall, result: MethodChannel.Result
) {
var sig = call.argument<ByteArray>("signature");
var hash = call.argument<ByteArray>("hash");
var pubKey = call.argument<ByteArray>("pubKey");
// private val secp256k1 = Secp256k1.get()

result.success(secp256k1.verifySchnorr(sig!!, hash!!, pubKey!!));
}
// @ExperimentalStdlibApi
// override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
// super.configureFlutterEngine(flutterEngine);
// MethodChannel(
// flutterEngine.dartExecutor.binaryMessenger,
// CHANNEL
// ).setMethodCallHandler { call, result ->
// when {
// call.method.equals("verifySignature") -> {
// verifySignature(call, result)
// }
// }
// }
// }
// fun verifySignature(
// call: MethodCall, result: MethodChannel.Result
// ) {
// var sig = call.argument<ByteArray>("signature");
// var hash = call.argument<ByteArray>("hash");
// var pubKey = call.argument<ByteArray>("pubKey");
//
// result.success(secp256k1.verifySchnorr(sig!!, hash!!, pubKey!!));
// }

// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// super.onActivityResult(requestCode, resultCode, data)
Expand Down
9 changes: 4 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sizer/sizer.dart';
import 'package:window_manager/window_manager.dart';
import 'package:yana/hybrid_event_verifier.dart';
import 'package:yana/nostr/nip07/extension_event_signer.dart';
import 'package:yana/provider/badge_definition_provider.dart';
import 'package:yana/provider/community_info_provider.dart';
Expand Down Expand Up @@ -176,7 +175,7 @@ late PackageInfo packageInfo;

FlutterBackgroundService? backgroundService;

late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
// late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

int c = 0;

Expand Down Expand Up @@ -252,7 +251,7 @@ Future<void> initProvidersAndStuff() async {
cacheManager = dbCacheManager;
dbCacheManager.eventFilter = filterProvider;
relayManager.cacheManager = cacheManager;
relayManager.eventVerifier = HybridEventVerifier();
// relayManager.eventVerifier = HybridEventVerifier();

if (myInboxRelaySet==null) {
await relayManager.connect();
Expand Down Expand Up @@ -427,7 +426,7 @@ Future<void> main() async {
cacheManager = relayManager.cacheManager;
print(e);
}
relayManager.eventVerifier = HybridEventVerifier();
// relayManager.eventVerifier = HybridEventVerifier();

if (!PlatformUtil.isWeb() && PlatformUtil.isPC()) {
await windowManager.ensureInitialized();
Expand Down Expand Up @@ -557,7 +556,7 @@ void initBackgroundService(bool startOnBoot) async {
importance: Importance.low, // importance must be at low or higher level
);

flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
var flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
// if (startOnBoot) {
backgroundService = FlutterBackgroundService();
await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()?.createNotificationChannel(channel);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ packages:
dependency: "direct main"
description:
name: dart_ndk
sha256: b615de1684fbd058aa93cd7136ea0595197e97dcea95a69d5e5128f3a1572284
sha256: "50a75d6648ae8ddf113d99e9c9dda104e8208096fe36f7f7f543b274e89a3e1b"
url: "https://pub.dev"
source: hosted
version: "0.1.0-dev5"
version: "0.1.0-dev6"
dart_style:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ dependencies:
# git:
# url: https://github.com/relaystr/dart_ndk.git
# ref: master
dart_ndk: 0.1.0-dev5
# path: ../dart_ndk
dart_ndk: 0.1.0-dev6
#path: ../dart_ndk

dev_dependencies:
flutter_launcher_icons: ^0.13.1
Expand Down

0 comments on commit 2c7a8cd

Please sign in to comment.