Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] native channel dart binding

Priyanshu Dangaredb044cc9ac6a
diff --git a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MainActivity.kt b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MainActivity.kt
index 7422f67826..e60dbc6c9c 100644
--- a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MainActivity.kt
+++ b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/MainActivity.kt
@@ -2,8 +2,17 @@ package io.ente.photos
import android.content.Intent
import io.flutter.embedding.android.FlutterFragmentActivity
+import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterFragmentActivity() {
+ override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
+ super.configureFlutterEngine(flutterEngine)
+ NativeChannel.register(
+ flutterEngine.dartExecutor.binaryMessenger,
+ contentResolver,
+ )
+ }
+
override fun onNewIntent(intent: Intent) {
setIntent(intent)
super.onNewIntent(intent)
diff --git a/mobile/apps/photos/lib/services/native_service.dart b/mobile/apps/photos/lib/services/native_service.dart
new file mode 100644
index 0000000000..20549adef3
--- /dev/null
+++ b/mobile/apps/photos/lib/services/native_service.dart
@@ -0,0 +1,35 @@
+import "dart:io";
+
+import "package:flutter/services.dart";
+
+class NativeTrashFile {
+ final int localID;
+ final int deleteBy;
+ final String deviceFolder;
+
+ const NativeTrashFile({
+ required this.localID,
+ required this.deleteBy,
+ required this.deviceFolder,
+ });
+}
+
+class NativeService {
+ NativeService._();
+
+ static const _channel = MethodChannel("ente.io/photos/native");
+
+ static Future<List<NativeTrashFile>> getTrash() async {
+ if (!Platform.isAndroid) return const [];
+
+ final files = await _channel.invokeListMethod<Object?>("getTrash") ?? [];
+ return files.map((file) {
+ final map = file! as Map<Object?, Object?>;
+ return NativeTrashFile(
+ localID: map["localID"]! as int,
+ deleteBy: map["deleteBy"]! as int,
+ deviceFolder: map["deviceFolder"]! as String,
+ );
+ }).toList();
+ }
+}