Skip to content

Commit

Permalink
Improve WSA connection status checks
Browse files Browse the repository at this point in the history
  • Loading branch information
alesimula committed Dec 21, 2021
1 parent cdcf58d commit ff3ed07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/apk_installer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _ApkInstallerState extends State<ApkInstaller> {
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);
Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class WSAStatusAlert {
// Do nothing for now
}(),
);

bool get isConnected => type == ConnectionStatus.CONNECTED;
bool get isDisconnected => type != ConnectionStatus.CONNECTED;
}

enum ConnectionStatus {
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/wsa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class _ScreenWSAState extends State<ScreenWSA> {
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'])
),
Expand All @@ -90,7 +90,7 @@ class _ScreenWSAState extends State<ScreenWSA> {
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']) ),
)
Expand Down

0 comments on commit ff3ed07

Please sign in to comment.