Skip to content

Commit

Permalink
[FIX] Auth desktop (#1234)
Browse files Browse the repository at this point in the history
Fixes for auth desktop
- Install Dir path and name fix
- Install/Uninstall Icon fix
- Don't check "add Desktop icon" by default
- Fix Exit app in system tray
  • Loading branch information
prateekmedia authored Mar 28, 2024
2 parents e4ce144 + fbd673c commit 9e93dc5
Show file tree
Hide file tree
Showing 22 changed files with 286 additions and 186 deletions.
File renamed without changes
File renamed without changes
Binary file removed auth/assets/icon-light.ico
Binary file not shown.
Binary file added auth/assets/icons/auth-icon.ico
Binary file not shown.
File renamed without changes
12 changes: 6 additions & 6 deletions auth/fdroid_flutter_icons.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
flutter_icons:
android: "launcher_icon"
image_path: "assets/icon-light.png"
adaptive_icon_foreground: "assets/icon-light-adaptive-fg.png"
adaptive_icon_background: "#ffffff"

flutter_icons:
android: "launcher_icon"
image_path: "assets/generation-icons/icon-light.png"
adaptive_icon_foreground: "assets/generation-icons/icon-light-adaptive-fg.png"
adaptive_icon_background: "#ffffff"

47 changes: 43 additions & 4 deletions auth/lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:ente_auth/ui/settings/app_update_dialog.dart';
import 'package:flutter/foundation.dart';
import "package:flutter/material.dart";
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:system_tray/system_tray.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

class App extends StatefulWidget {
Expand All @@ -34,7 +34,7 @@ class App extends StatefulWidget {
State<App> createState() => _AppState();
}

class _AppState extends State<App> with WindowListener {
class _AppState extends State<App> with WindowListener, TrayListener {
late StreamSubscription<SignedOutEvent> _signedOutEvent;
late StreamSubscription<SignedInEvent> _signedInEvent;
Locale? locale;
Expand All @@ -49,9 +49,15 @@ class _AppState extends State<App> with WindowListener {
await windowManager.setPreventClose(true);
}

Future<void> initTrayManager() async {
trayManager.addListener(this);
}

@override
void initState() {
initWindowManager();
initTrayManager();

_signedOutEvent = Bus.instance.on<SignedOutEvent>().listen((event) {
if (mounted) {
setState(() {});
Expand Down Expand Up @@ -85,7 +91,10 @@ class _AppState extends State<App> with WindowListener {
@override
void dispose() {
super.dispose();

windowManager.removeListener(this);
trayManager.removeListener(this);

_signedOutEvent.cancel();
_signedInEvent.cancel();
}
Expand Down Expand Up @@ -147,12 +156,42 @@ class _AppState extends State<App> with WindowListener {

@override
void onWindowClose() async {
final AppWindow appWindow = AppWindow();
await appWindow.hide();
await windowManager.hide();
}

@override
void onWindowResize() {
WindowListenerService.instance.onWindowResize().ignore();
}

@override
void onTrayIconMouseDown() {
if (Platform.isWindows) {
windowManager.show();
} else {
trayManager.popUpContextMenu();
}
}

@override
void onTrayIconRightMouseDown() {
if (Platform.isWindows) {
trayManager.popUpContextMenu();
} else {
windowManager.show();
}
}

@override
void onTrayIconRightMouseUp() {}

@override
void onTrayMenuItemClick(MenuItem menuItem) {
if (menuItem.key == 'show_window') {
windowManager.show();
} else if (menuItem.key == 'exit_app') {
windowManager.setPreventClose(false);
windowManager.close();
}
}
}
48 changes: 18 additions & 30 deletions auth/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,30 @@ import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:privacy_screen/privacy_screen.dart';
import 'package:system_tray/system_tray.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

final _logger = Logger("main");

Future<void> initSystemTray() async {
String path =
Platform.isWindows ? 'assets/icon-light.ico' : 'assets/icon-light.png';

final AppWindow appWindow = AppWindow();
final SystemTray systemTray = SystemTray();

// We first init the systray menu
await systemTray.initSystemTray(
title: "",
iconPath: path,
String path = Platform.isWindows
? 'assets/icons/auth-icon.ico'
: 'assets/icons/auth-icon.png';
await trayManager.setIcon(path);
Menu menu = Menu(
items: [
MenuItem(
key: 'show_window',
label: 'Show Window',
),
MenuItem.separator(),
MenuItem(
key: 'exit_app',
label: 'Exit App',
),
],
);

// create context menu
final show = MenuItem(label: 'Show', onClicked: () => appWindow.show());
final hide = MenuItem(label: 'Hide', onClicked: () => appWindow.hide());
final exit = MenuItem(label: 'Exit', onClicked: () => appWindow.close());

// set context menu
await systemTray.setContextMenu([show, hide, exit]);

const kSystemTrayEventClick = 'leftMouseDown';
const kSystemTrayEventRightClick = 'rightMouseDown';
// // handle system tray event
systemTray.registerSystemTrayEventHandler((eventName) {
if (eventName == kSystemTrayEventClick) {
Platform.isWindows ? appWindow.show() : systemTray.popUpContextMenu();
} else if (eventName == kSystemTrayEventRightClick) {
Platform.isWindows ? systemTray.popUpContextMenu() : appWindow.show();
}
});
await trayManager.setContextMenu(menu);
}

void main() async {
Expand Down
2 changes: 1 addition & 1 deletion auth/lib/utils/auth_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
import 'package:local_auth/local_auth.dart';
import 'package:local_auth_android/local_auth_android.dart';
import 'package:local_auth_ios/types/auth_messages_ios.dart';
import 'package:local_auth_darwin/types/auth_messages_ios.dart';
import 'package:logging/logging.dart';

Future<bool> requestAuthentication(BuildContext context, String reason) async {
Expand Down
8 changes: 4 additions & 4 deletions auth/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <smart_auth/smart_auth_plugin.h>
#include <sodium_libs/sodium_libs_plugin.h>
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
#include <system_tray/system_tray_plugin.h>
#include <tray_manager/tray_manager_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>

Expand Down Expand Up @@ -51,9 +51,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
g_autoptr(FlPluginRegistrar) system_tray_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin");
system_tray_plugin_register_with_registrar(system_tray_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);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
2 changes: 1 addition & 1 deletion auth/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
smart_auth
sodium_libs
sqlite3_flutter_libs
system_tray
tray_manager
url_launcher_linux
window_manager
)
Expand Down
52 changes: 26 additions & 26 deletions auth/linux/packaging/appimage/make_config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
display_name: Auth
license: GPLv3

icon: assets/icon/auth-icon.png

keywords:
- Authentication
- 2FA

generic_name: ente Auth

categories:
- Utility

startup_notify: false

# You can specify the shared libraries that you want to bundle with your app
#
# flutter_distributor automatically detects the shared libraries that your app
# depends on, but you can also specify them manually here.
#
# The following example shows how to bundle the libcurl library with your app.
#
# include:
# - libcurl.so.4
include: []
display_name: Auth
license: GPLv3

icon: assets/icons/auth-icon.png

keywords:
- Authentication
- 2FA

generic_name: ente Auth

categories:
- Utility

startup_notify: false

# You can specify the shared libraries that you want to bundle with your app
#
# flutter_distributor automatically detects the shared libraries that your app
# depends on, but you can also specify them manually here.
#
# The following example shows how to bundle the libcurl library with your app.
#
# include:
# - libcurl.so.4
include: []
68 changes: 34 additions & 34 deletions auth/linux/packaging/deb/make_config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
display_name: Auth
package_name: auth
maintainer:
name: Ente.io Developers
email: [email protected]
priority: optional
section: x11
essential: false
license: GPLv3
icon: assets/icon/auth-icon.png
installed_size: 36000

dependencies:
- libwebkit2gtk-4.0-37
- libsqlite3-0
- libsodium23
- libsecret-1-0
- libappindicator3-1 | libayatana-appindicator3-1
- gir1.2-appindicator3-0.1 | gir1.2-ayatanaappindicator3-0.1
- libayatana-ido3-0.4-0

keywords:
- Authentication
- 2FA

generic_name: Ente Authentication

categories:
- Utility

startup_notify: false

supported_mime_type:
- x-scheme-handler/ente
display_name: Auth
package_name: auth
maintainer:
name: Ente.io Developers
email: [email protected]
priority: optional
section: x11
essential: false
license: GPLv3
icon: assets/icons/auth-icon.png
installed_size: 36000

dependencies:
- libwebkit2gtk-4.0-37
- libsqlite3-0
- libsodium23
- libsecret-1-0
- libappindicator3-1 | libayatana-appindicator3-1
- gir1.2-appindicator3-0.1 | gir1.2-ayatanaappindicator3-0.1
- libayatana-ido3-0.4-0

keywords:
- Authentication
- 2FA

generic_name: Ente Authentication

categories:
- Utility

startup_notify: false

supported_mime_type:
- x-scheme-handler/ente
62 changes: 31 additions & 31 deletions auth/linux/packaging/rpm/make_config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
icon: assets/icon/auth-icon.png
summary: 2FA app with free end-to-end encrypted backup and sync
group: Application/Utility
vendor: Ente.io
packager: Ente.io Developers
packagerEmail: [email protected]
license: GPLv3
url: https://github.com/ente-io/ente

display_name: Auth

dependencies:
- libsqlite3x
- webkit2gtk-4.0
- libsodium
- libsecret
- libappindicator

keywords:
- Authentication
- 2FA

generic_name: Ente Authentication

categories:
- Utility

startup_notify: false

supported_mime_type:
- x-scheme-handler/ente
icon: assets/icons/auth-icon.png
summary: 2FA app with free end-to-end encrypted backup and sync
group: Application/Utility
vendor: Ente.io
packager: Ente.io Developers
packagerEmail: [email protected]
license: GPLv3
url: https://github.com/ente-io/ente

display_name: Auth

dependencies:
- libsqlite3x
- webkit2gtk-4.0
- libsodium
- libsecret
- libappindicator

keywords:
- Authentication
- 2FA

generic_name: Ente Authentication

categories:
- Utility

startup_notify: false

supported_mime_type:
- x-scheme-handler/ente
Loading

0 comments on commit 9e93dc5

Please sign in to comment.