Skip to content

Commit

Permalink
Updating to 0.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmailAlamKhan committed Jul 23, 2023
1 parent 33f4945 commit 217432f
Show file tree
Hide file tree
Showing 21 changed files with 635 additions and 357 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG-ALL.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.0.15

- Fixed input text bug
- Fixed the ui problem on about page
- Re-arrenged the device options(commands)
- Added new device options(commands)
- Uninstall apk
- Added cancel button on connect wireless dialog
## 0.0.14

- Fix app initialization
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.14
## 0.0.15

- Fix app initialization
- Fixed input text bug
- Fixed the ui problem on about page
- Re-arrenged the device options(commands)
- Added new device options(commands)
- Uninstall apk
- Added cancel button on connect wireless dialog
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ linter:
library_private_types_in_public_api: false
no_leading_underscores_for_local_identifiers: false
use_super_parameters: true
unused_element: false

analyzer:
exclude:
Expand Down
38 changes: 24 additions & 14 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'dart:ui';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:window_manager/window_manager.dart';

Expand Down Expand Up @@ -51,22 +53,28 @@ class App {
}

static Future<void> run() async {
WidgetsFlutterBinding.ensureInitialized();
NavigatorService.init();
AppLogger.init();
await LogFile.init();

FlutterError.onError = LogFile.instance.dispatchFlutterErrorLogs;
final container = ProviderContainer();
runZonedGuarded(
() async {
WidgetsFlutterBinding.ensureInitialized();
NavigatorService.init();
AppLogger.init();
await LogFile.init();

GoogleFonts.pendingFonts([GoogleFonts.poppinsTextTheme()]);

FlutterError.onError = LogFile.instance.dispatchFlutterErrorLogs;
await init(container);
runApp(UncontrolledProviderScope(
container: container,
child: const _App(),
));
},
(error, stack) {
(error, stack) async {
WidgetsFlutterBinding.ensureInitialized();
NavigatorService.init();
AppLogger.init();
await LogFile.init();
if (error is AppInitializationException) {
runApp(UncontrolledProviderScope(
container: container,
Expand Down Expand Up @@ -168,7 +176,8 @@ class WindowTitleBar extends StatelessWidget {
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return CustomMenuBar(
child: MediaQuery.fromWindow(
child: MediaQuery.fromView(
view: View.of(context),
child: Builder(
builder: (context) {
return MediaQuery(
Expand Down Expand Up @@ -211,9 +220,9 @@ class WindowTitleBar extends StatelessWidget {
brightness: Theme.of(context).brightness,
backgroundColor: Colors.transparent,
title: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyText2!,
child: Row(
children: const [
style: Theme.of(context).textTheme.bodyMedium!,
child: const Row(
children: [
AppLogo(size: 20),
Gap(4),
Text(appName),
Expand Down Expand Up @@ -275,9 +284,10 @@ class __AppThemeBuilderState extends State<_AppThemeBuilder> with WidgetsBinding
void _updateThemeMode([bool inital = false]) {
ThemeMode themeMode = widget.themeMode;
if (themeMode == ThemeMode.system) {
themeMode = _binding.window.platformBrightness == Brightness.dark //
? ThemeMode.dark
: ThemeMode.light;
themeMode =
SchedulerBinding.instance.platformDispatcher.platformBrightness == Brightness.dark //
? ThemeMode.dark
: ThemeMode.light;
}
if (themeMode != this.themeMode) {
if (!inital) {
Expand Down
22 changes: 14 additions & 8 deletions lib/app/features/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,31 @@ class AboutView extends ConsumerWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppBar(title: const Text('About $appName'), toolbarHeight: 40),
AppBar(
title: const Text('About $appName'),
toolbarHeight: 40,
elevation: 0,
surfaceTintColor: Colors.transparent,
backgroundColor: Colors.transparent,
),
const Gap(8),
Row(
const Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const AppLogo(size: 100),
const Gap(8),
AppLogo(size: 100),
Gap(8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const _UpdateChecker(),
const Gap(8),
_UpdateChecker(),
Gap(8),
Padding(
padding: const EdgeInsets.only(left: 40),
padding: EdgeInsets.only(left: 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
_CurrentVersion(),
Gap(8),
_ReportBug(),
Expand Down
23 changes: 20 additions & 3 deletions lib/app/features/adb/adb_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ class AdbController with NavigationController {

Future<void> connect() async {
final nativeWirelessDebugSupported = await confirmDialog(
(context) => 'Do you have android 11 or higher?',
title: 'Android 11 or higher required',
);
(context) => 'Do you have android 11 or higher?',
title: 'Android 11 or higher required',
extraActions: [
ConfirmDialogAction(onPressed: () => pop(), text: 'Cancel'),
]);
if (nativeWirelessDebugSupported == null) {
return;
}
Expand Down Expand Up @@ -348,4 +350,19 @@ class AdbController with NavigationController {
command: 'Input text',
);
}

Future<void> uninstallApp(AdbDevice device) async {
final packageName = await showDialog<String>(
pageBuilder: (_) => AdbInputDialog.single(
title: 'Enter your package name',
label: 'package name',
),
);

if (packageName == null) return;
run(
function: () => service.uninstallApp(device, packageName),
command: 'Uninstall app',
);
}
}
47 changes: 27 additions & 20 deletions lib/app/features/adb/adb_dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,6 @@ class AdbDeviceDialog extends ConsumerWidget {
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: const Text('Copy id'),
onTap: () {
Navigator.of(context).pop();
Clipboard.setData(ClipboardData(text: device.id));
},
),
ListTile(
title: const Text('Disconnect'),
subtitle: const Text('Only available for WIFI devices'),
onTap: () {
Navigator.of(context).pop();
controller.disconnect(device);
},
),
if (!device.isOffline) ...[
ListTile(
title: const Text('Install apk'),
Expand All @@ -145,6 +130,13 @@ class AdbDeviceDialog extends ConsumerWidget {
controller.installApk(device);
},
),
ListTile(
title: const Text('Uninstall app'),
onTap: () {
Navigator.of(context).pop();
controller.uninstallApp(device);
},
),
ListTile(
title: const Text('Push file'),
onTap: () {
Expand All @@ -160,17 +152,17 @@ class AdbDeviceDialog extends ConsumerWidget {
},
),
ListTile(
title: const Text('Run command'),
title: const Text('Input text'),
onTap: () {
Navigator.of(context).pop();
controller.runCommand(device);
controller.inputText(device);
},
),
ListTile(
title: const Text('Input text'),
title: const Text('Run command'),
onTap: () {
Navigator.of(context).pop();
controller.inputText(device);
controller.runCommand(device);
},
),
ListTile(
Expand All @@ -186,7 +178,22 @@ class AdbDeviceDialog extends ConsumerWidget {
controller.runScrcpy(device);
},
),
]
],
ListTile(
title: const Text('Copy id'),
onTap: () {
Navigator.of(context).pop();
Clipboard.setData(ClipboardData(text: device.id));
},
),
ListTile(
title: const Text('Disconnect'),
subtitle: const Text('Only available for WIFI devices'),
onTap: () {
Navigator.of(context).pop();
controller.disconnect(device);
},
),
],
),
),
Expand Down
52 changes: 38 additions & 14 deletions lib/app/features/adb/adb_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ abstract class AdbService {

Future<Result> inputText(AdbDevice device, String text);

Future<Result> uninstallApp(AdbDevice device, String packageName);

/// -connnected device commands-
/// -commands-
Expand Down Expand Up @@ -155,8 +157,8 @@ Future<Map<String, String>?> _loadUnixEnvironment() async {
await Future.delayed(const Duration(milliseconds: 300));

// execution permissions (no need to get result).
final chmodResult = io.Process.runSync('chmod', ['u+x', 'env.sh'],
workingDirectory: supportDir.absolute.path);
final chmodResult =
io.Process.runSync('chmod', ['u+x', 'env.sh'], workingDirectory: supportDir.absolute.path);
LogFile.instance.dispath(
"Permission result (${chmodResult.exitCode}) - out=${chmodResult.stdout} - err=${chmodResult.stderr}");

Expand Down Expand Up @@ -415,7 +417,6 @@ class ProccessAdbServiceImpl implements AdbService {
element.name == 'odm' ||
element.name == 'lost+found' ||
element.name == 'bugreports' ||

element.name == 'sys' ||
element.name == 'system' ||
element.name == 'apex' ||
Expand Down Expand Up @@ -552,17 +553,21 @@ class ProccessAdbServiceImpl implements AdbService {
});

@override
Future<Result> inputText(AdbDevice device, String text) =>
run('shell', device: device, arguments: ['input', 'text', text])
.then((value) => value.copyWith(
messege: value.stdout.then((value) {
if (value.isEmpty) {
return 'Text sent';
}
logError('Failed to send text', error: value);
throw AppException('Failed to send text cause $value');
}),
));
Future<Result> inputText(AdbDevice device, String text) {
text = text.replaceAll('\'', '\\\'').replaceAll('"', '\\"').replaceAll(' ', '%s');
logInfo('Text: $text');
return run('shell', device: device, arguments: ['input', 'text', text])
.then((value) => value.copyWith(
messege: value.stdout.then((value) {
if (value.isEmpty) {
return 'Text sent';
}
logError('Failed to send text', error: value);
throw AppException('Failed to send text cause $value');
}),
));
}

@override
Future<Result> rerunCommand(
String command,
Expand Down Expand Up @@ -609,6 +614,25 @@ class ProccessAdbServiceImpl implements AdbService {
throw AppException('Command not found');
}
}

@override
Future<Result> uninstallApp(AdbDevice device, String packageName) {
return run(
'uninstall',
arguments: [packageName],
device: device,
).then((result) async {
return result.copyWith(
messege: result.stdout.then((output) {
if (output.contains('Success')) {
return 'Uninstalled $packageName';
}
logError('Failed to uninstall $packageName', error: output);
throw AppException('Failed to uninstall cause $output');
}),
);
});
}
}

class PermissionDeniedException extends AppException {
Expand Down
2 changes: 1 addition & 1 deletion lib/app/features/command_queue/command_queue_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CommandQueueView extends HookConsumerWidget {
if (command.isRerun)
TextSpan(
text: ' (rerun)',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/app/features/home/home_view_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HomeViewContent extends ConsumerWidget {
padding: const EdgeInsets.all(8),
child: Text(
'${connectedDevices.length} Connected device(s)',
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.titleLarge,
),
),
),
Expand All @@ -42,7 +42,7 @@ class HomeViewContent extends ConsumerWidget {
if (device.isOffline)
TextSpan(
text: ' (Offline)',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
Expand Down
3 changes: 2 additions & 1 deletion lib/app/features/splash/splash_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class SplashView extends StatefulWidget {
class _SplashViewState extends State<SplashView> {
@override
Widget build(BuildContext context) {
return MediaQuery.fromWindow(
return MediaQuery.fromView(
view: View.of(context),
child: Builder(builder: (context) {
final mq = MediaQuery.of(context);
final theme = mq.platformBrightness == Brightness.dark
Expand Down
Loading

0 comments on commit 217432f

Please sign in to comment.