Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Jan 10, 2024
1 parent ed4db4b commit eb7e190
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 39 deletions.
4 changes: 3 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ android {

compileSdk project.compileSdkVersion

ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -109,7 +111,7 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation 'androidx.preference:preference-ktx:1.2.1'

implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'

implementation 'com.github.tony19:logback-android:3.0.0'

Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />

<provider
android:name="com.superlist.super_native_extensions.DataProvider"
android:authorities="com.yubico.yubioath.SuperClipboardDataProvider"
android:exported="true"
android:grantUriPermissions="true" >
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ import android.view.WindowManager
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import androidx.lifecycle.get
import androidx.lifecycle.lifecycleScope
import com.yubico.authenticator.logging.FlutterLog
import com.yubico.authenticator.oath.AppLinkMethodChannel
Expand All @@ -48,6 +53,7 @@ import com.yubico.yubikit.android.transport.nfc.NfcNotAvailable
import com.yubico.yubikit.android.transport.nfc.NfcYubiKeyDevice
import com.yubico.yubikit.android.transport.usb.UsbConfiguration
import com.yubico.yubikit.core.YubiKeyDevice
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.BinaryMessenger
Expand All @@ -58,9 +64,20 @@ import org.slf4j.LoggerFactory
import java.io.Closeable
import java.util.concurrent.Executors

class MainActivity : FlutterFragmentActivity() {
private val viewModel: MainViewModel by viewModels()
private val oathViewModel: OathViewModel by viewModels()
class MainActivity : FlutterActivity(), ViewModelStoreOwner {

private val activityViewModelStore: ViewModelStore by lazy {
ViewModelStore()
}

override public val viewModelStore: ViewModelStore = activityViewModelStore

private val viewModel: MainViewModel by lazy {
ViewModelProvider(this).get(MainViewModel::class.java)
}
private val oathViewModel: OathViewModel by lazy {
ViewModelProvider(this).get(OathViewModel::class.java)
}

private val nfcConfiguration = NfcConfiguration()

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ allprojects {
}

project.ext {
minSdkVersion = 21
minSdkVersion = 23
targetSdkVersion = 34
compileSdkVersion = 34

Expand Down
15 changes: 15 additions & 0 deletions lib/oath/views/add_account_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _AddAccountDialogState extends ConsumerState<AddAccountDialog> {
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: FileDropTarget(
onFileDropped: (fileData) async {
debugPrint('onFileDropped');
Navigator.of(context).pop();
if (qrScanner != null) {
final b64Image = base64Encode(fileData);
Expand All @@ -70,6 +71,8 @@ class _AddAccountDialogState extends ConsumerState<AddAccountDialog> {
}
},
);
} else {
debugPrint('no QR scanner');
}
},
child: Column(
Expand Down Expand Up @@ -134,4 +137,16 @@ class _AddAccountDialogState extends ConsumerState<AddAccountDialog> {
),
));
}

@override
void dispose() {
super.dispose();
debugPrint('disposed :(');
}

@override
void deactivate() {
super.deactivate();
debugPrint('deactivated :(');
}
}
53 changes: 44 additions & 9 deletions lib/widgets/file_drop_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import 'package:desktop_drop/desktop_drop.dart';
import 'package:flutter/material.dart';
import 'package:super_drag_and_drop/super_drag_and_drop.dart';

import '../core/state.dart';
import '../android/app_methods.dart';

class FileDropTarget extends StatefulWidget {
final Widget child;
Expand Down Expand Up @@ -50,23 +50,58 @@ class _FileDropTargetState extends State<FileDropTarget> {
);

@override
Widget build(BuildContext context) => DropTarget(
onDragEntered: (_) {
Widget build(BuildContext context) => DropRegion(
formats: Formats.standardFormats,
//hitTestBehavior: HitTestBehavior.opaque,
onDropEnter: (_) async {
setState(() {
_hovering = true;
});
},
onDragExited: (_) {
onDropLeave: (_) {
setState(() {
_hovering = false;
});
},
onDragDone: (details) async {
for (final file in details.files) {
widget.onFileDropped(await file.readAsBytes());
onDropEnded: (event) async {
setState(() {
_hovering = false;
});
await preserveConnectedDeviceWhenPaused();
},
onDropOver: (event) async {
debugPrint('onDropOver');
return event.session.allowedOperations.firstOrNull ??
DropOperation.none;
},
onPerformDrop: (PerformDropEvent event) async {

debugPrint('onPerform');
final reader = event.session.items.firstOrNull?.dataReader;
if (reader != null) {
if (reader.canProvide(Formats.jpeg)) {
debugPrint('received jpeg');
reader.getFile(Formats.jpeg, (file) async {
widget.onFileDropped(await file.readAll());
});
}

if (reader.canProvide(Formats.png)) {
debugPrint('received png');
reader.getFile(Formats.png, (file) async {
debugPrint('reading png data');
final data = await file.readAll();
debugPrint('have the png data: ${data.length}');
widget.onFileDropped(data);
debugPrint('leaving function');
}, onError: (err) {
debugPrint('error getting png file');
});
}
}
debugPrint('leaving onPerform');
},
enable: !isAndroid,

child: Stack(
alignment: Alignment.center,
children: [
Expand Down
12 changes: 8 additions & 4 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@

#include "generated_plugin_registrant.h"

#include <desktop_drop/desktop_drop_plugin.h>
#include <irondash_engine_context/irondash_engine_context_plugin.h>
#include <local_notifier/local_notifier_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <super_native_extensions/super_native_extensions_plugin.h>
#include <tray_manager/tray_manager_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) desktop_drop_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin");
desktop_drop_plugin_register_with_registrar(desktop_drop_registrar);
g_autoptr(FlPluginRegistrar) irondash_engine_context_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "IrondashEngineContextPlugin");
irondash_engine_context_plugin_register_with_registrar(irondash_engine_context_registrar);
g_autoptr(FlPluginRegistrar) local_notifier_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "LocalNotifierPlugin");
local_notifier_plugin_register_with_registrar(local_notifier_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
g_autoptr(FlPluginRegistrar) super_native_extensions_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SuperNativeExtensionsPlugin");
super_native_extensions_plugin_register_with_registrar(super_native_extensions_registrar);
g_autoptr(FlPluginRegistrar) tray_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");
tray_manager_plugin_register_with_registrar(tray_manager_registrar);
Expand Down
3 changes: 2 additions & 1 deletion linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
desktop_drop
irondash_engine_context
local_notifier
screen_retriever
super_native_extensions
tray_manager
url_launcher_linux
window_manager
Expand Down
8 changes: 6 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
import FlutterMacOS
import Foundation

import desktop_drop
import device_info_plus
import irondash_engine_context
import local_notifier
import path_provider_foundation
import screen_retriever
import shared_preferences_foundation
import super_native_extensions
import tray_manager
import url_launcher_macos
import window_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin"))
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
Expand Down
82 changes: 69 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e
url: "https://pub.dev"
source: hosted
version: "0.3.3+8"
crypto:
dependency: "direct main"
description:
Expand Down Expand Up @@ -241,14 +233,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.4"
desktop_drop:
dependency: "direct main"
device_info_plus:
dependency: transitive
description:
name: device_info_plus
sha256: "0042cb3b2a76413ea5f8a2b40cec2a33e01d0c937e91f0f7c211fde4f7739ba6"
url: "https://pub.dev"
source: hosted
version: "9.1.1"
device_info_plus_platform_interface:
dependency: transitive
description:
name: desktop_drop
sha256: d55a010fe46c8e8fcff4ea4b451a9ff84a162217bdb3b2a0aa1479776205e15d
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.dev"
source: hosted
version: "0.4.4"
version: "7.0.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -428,6 +428,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
irondash_engine_context:
dependency: transitive
description:
name: irondash_engine_context
sha256: "0e803321935ca7af1a88f1391be9edfdb940df800353670bfc694934c7643ff3"
url: "https://pub.dev"
source: hosted
version: "0.4.1"
irondash_message_channel:
dependency: transitive
description:
name: irondash_message_channel
sha256: "500daa1fbe679f7d28a5258df3ff47dab6de352e680dc93c1ca9eae1555d8db5"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -603,6 +619,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.2"
pixel_snap:
dependency: transitive
description:
name: pixel_snap
sha256: d31591a4f4aa8ed5dc6fc00b8d027338a5614dfbf5ca658b69d1faa7aba80af7
url: "https://pub.dev"
source: hosted
version: "0.1.4"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -839,6 +863,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
super_clipboard:
dependency: transitive
description:
name: super_clipboard
sha256: "10774204b35b68f8dc5884ab620f83220d2c12620a8dcf4e6f39c94666f3549f"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
super_drag_and_drop:
dependency: "direct main"
description:
name: super_drag_and_drop
sha256: cb884e24f75127ddfba7908808ac265249075511c72584148345b259ca99788c
url: "https://pub.dev"
source: hosted
version: "0.7.0"
super_native_extensions:
dependency: transitive
description:
name: super_native_extensions
sha256: b2fb454a90308f4f25e8ab928272490883d87a28d362307678c76989287cae43
url: "https://pub.dev"
source: hosted
version: "0.7.0"
sync_http:
dependency: transitive
description:
Expand Down Expand Up @@ -1046,6 +1094,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.1.1"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
window_manager:
dependency: "direct main"
description:
Expand Down
Loading

0 comments on commit eb7e190

Please sign in to comment.