Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"error": {
"scrcpy": {
"notFound": {
"title": "Scrcpy not found",
"message": "Scrcpy not found in path. Please make sure if it's installed. If already installed, please configure the path in settings."
"title": "Scrcpy could not be found",
"message": "Please make sure if it's installed. If already installed, please configure the path in settings."
},
"failedToStart": "Failed to start scrcpy",
"unexpectedStop": {
Expand All @@ -40,7 +40,7 @@
}
}
},
"goToSettings": "Go to settings",
"openSettings": "Open settings",
"profile": {
"default": "Default",
"manage": "Manage profiles",
Expand Down Expand Up @@ -83,6 +83,12 @@
"serial": "Serial",
"actions": "Actions"
},
"adbNotFound": {
"title": "ADB could not be found",
"hint": "What is ADB?",
"description": "Please make sure if it's installed. If already installed, please configure the path in ",
"settings": "settings"
},
"copy": "Copy",
"stop": "Stop",
"toNetwork": "To Network",
Expand All @@ -100,14 +106,14 @@
"adbExecutable": {
"title": "adb executable",
"dialogTitle": "adb scrcpy executable",
"description": "Explicitly set adb executable path.\nSet this in case the executable is not added to $PATH or, the tool can't find it.",
"description": "Explicitly set adb executable path.\nSet this in case the executable is not added to $PATH, or the app can't find it.",
"invalidPath": "Invalid path provided",
"check": "Check"
},
"scrcpyExecutable": {
"title": "scrcpy executable",
"dialogTitle": "Select scrcpy executable",
"description": "Explicitly set scrcpy executable path.\nSet this in case the executable is not added to $PATH or, the tool can't find it.",
"description": "Explicitly set scrcpy executable path.\nSet this in case the executable is not added to $PATH, or the app can't find it.",
"invalidPath": "Invalid path provided",
"check": "Check"
},
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/devices/bloc/devices_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class DevicesBloc extends Bloc<DevicesEvent, DevicesState> {
.where((device) => device.status == AdbDeviceStatus.device)
.map((d) => d.serial)
.toSet();
final newSelectedDeviceSerials = _selectedDeviceSerials.where((serial) => currentSerials.contains(serial));
final newSelectedDeviceSerials = _selectedDeviceSerials.intersection(currentSerials);
_selectedDeviceSerials.clear();
_selectedDeviceSerials.addAll(newSelectedDeviceSerials);
_emitSuccess(emit);
},
);
} on ProcessException catch (e) {
} on ProcessException catch (_) {
emit(
DevicesUpdateError(
devices: _devices,
Expand Down
13 changes: 9 additions & 4 deletions lib/presentation/devices/devices_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:scrcpy_buddy/application/extension/adb_error_extension.dart';
import 'package:scrcpy_buddy/application/model/adb/adb_error.dart';
import 'package:scrcpy_buddy/application/scrcpy_bloc/scrcpy_bloc.dart';
import 'package:scrcpy_buddy/presentation/devices/bloc/devices_bloc.dart';
import 'package:scrcpy_buddy/presentation/devices/device_row.dart';
import 'package:scrcpy_buddy/presentation/devices/widget/adb_not_found_widget.dart';
import 'package:scrcpy_buddy/presentation/devices/widget/devices_header.dart';
import 'package:scrcpy_buddy/presentation/extension/context_extension.dart';
import 'package:scrcpy_buddy/presentation/extension/translation_extension.dart';
Expand Down Expand Up @@ -54,11 +56,14 @@ class _DevicesScreenState extends AppModuleState<DevicesScreen> {
const Center(child: ProgressBar()),
],
if (devicesState is DevicesUpdateError) ...[
Center(
child: Text(
devicesState.adbError?.message ?? context.translatedText(key: 'common.somethingWentWrong'),
if (devicesState.adbError is AdbNotFoundError)
AdbNotFoundWidget()
else
Center(
child: Text(
devicesState.adbError?.message ?? context.translatedText(key: 'common.somethingWentWrong'),
),
),
),
],
if (devicesState is DevicesUpdateSuccess) ...[
if (devicesState.devices.isEmpty) ...[
Expand Down
57 changes: 57 additions & 0 deletions lib/presentation/devices/widget/adb_not_found_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:go_router/go_router.dart';
import 'package:scrcpy_buddy/presentation/extension/context_extension.dart';
import 'package:scrcpy_buddy/presentation/scrcpy_config/widgets/link_span.dart';
import 'package:scrcpy_buddy/presentation/widgets/app_widgets.dart';
import 'package:scrcpy_buddy/routes.dart';
import 'package:url_launcher/url_launcher_string.dart';

class AdbNotFoundWidget extends AppStatelessWidget {
const AdbNotFoundWidget({super.key});

@override
String get module => 'devices.adbNotFound';

void _openAdbDocs() => _launchUrlString("https://developer.android.com/tools/adb");

void _launchUrlString(String url) async {
if (await canLaunchUrlString(url)) {
launchUrlString(url);
}
}

@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
mainAxisAlignment: .center,
children: [
WindowsIcon(WindowsIcons.warning),
const SizedBox(width: 4),
Text(translatedText(context, key: 'title'), style: context.typography.title),
],
),
const SizedBox(height: 8),
RichText(
textAlign: .center,
text: TextSpan(
style: context.typography.body,
children: [
TextSpan(text: translatedText(context, key: 'description')),
LinkSpan(
text: translatedText(context, key: 'settings'),
onTap: () => context.go(AppRoute.settings),
),
TextSpan(text: '\n'),
LinkSpan(
text: translatedText(context, key: 'hint'),
onTap: _openAdbDocs,
),
],
),
),
],
);
}
}
3 changes: 2 additions & 1 deletion lib/presentation/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ class _HomeScreenState extends AppModuleState<HomeScreen> with WindowListener, T
title: translatedText(key: 'error.scrcpy.notFound.title'),
content: translatedText(key: 'error.scrcpy.notFound.message'),
severity: InfoBarSeverity.error,
isLong: true,
action: HyperlinkButton(
child: Text(translatedText(key: 'goToSettings')),
child: Text(translatedText(key: 'openSettings')),
onPressed: () => router.push(AppRoute.settings),
),
);
Expand Down
Loading