From ff3ed075775d39c6d6713d4dedddb3d368d9ca18 Mon Sep 17 00:00:00 2001 From: Alex Sim Date: Tue, 21 Dec 2021 13:52:38 +0100 Subject: [PATCH] Improve WSA connection status checks --- lib/apk_installer.dart | 2 +- lib/main.dart | 3 +++ lib/screens/wsa.dart | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/apk_installer.dart b/lib/apk_installer.dart index 74099a0..81edf1c 100644 --- a/lib/apk_installer.dart +++ b/lib/apk_installer.dart @@ -75,7 +75,7 @@ class _ApkInstallerState extends State { Widget? aForeground = GState.apkForegroundIcon.of(context); Widget? lIcon = GState.apkIcon.of(context); WSAStatusAlert connectionStatus = GState.connectionStatus.of(context); - bool isConnected = connectionStatus.severity == InfoBarSeverity.success; + bool isConnected = connectionStatus.isConnected; InstallType? installType = GState.apkInstallType.of(context); bool canInstall = isConnected && installType != null && installType != InstallType.UNKNOWN; InstallState installState = GState.apkInstallState.of(context); diff --git a/lib/main.dart b/lib/main.dart index 44497a2..5401750 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,6 +58,9 @@ class WSAStatusAlert { // Do nothing for now }(), ); + + bool get isConnected => type == ConnectionStatus.CONNECTED; + bool get isDisconnected => type != ConnectionStatus.CONNECTED; } enum ConnectionStatus { diff --git a/lib/screens/wsa.dart b/lib/screens/wsa.dart index e32daa5..6c39d04 100644 --- a/lib/screens/wsa.dart +++ b/lib/screens/wsa.dart @@ -79,7 +79,7 @@ class _ScreenWSAState extends State { padding: const EdgeInsets.all(8.0), child: Row(children: [ Expanded( - child: Button(child: const Text('Manage Applications'), onPressed: connectionStatus.severity != InfoBarSeverity.success ? + child: Button(child: const Text('Manage Applications'), onPressed: connectionStatus.isDisconnected ? null : () => Process.run('${Env.TOOLS_DIR}\\adb.exe', ['-s', '${GState.ipAddress.of(context)}:${GState.androidPort.of(context)}', 'shell', r'am start com.android.settings/.Settings\$ManageApplicationsActivity']) ), @@ -90,7 +90,7 @@ class _ScreenWSAState extends State { padding: const EdgeInsets.all(8.0), child: Row(children: [ Expanded( - child: Button(child: const Text('Manage Settings'), onPressed: connectionStatus.severity != InfoBarSeverity.success ? + child: Button(child: const Text('Manage Settings'), onPressed: connectionStatus.isDisconnected ? null : () => Process.run('${Env.TOOLS_DIR}\\adb.exe', ['-s', '${GState.ipAddress.of(context)}:${GState.androidPort.of(context)}', 'shell', r'am start com.android.settings/.Settings']) ), )