Skip to content

Commit

Permalink
remove deprecated device_apps package
Browse files Browse the repository at this point in the history
replace with AppCheck
  • Loading branch information
dreautall committed Oct 26, 2024
1 parent 51ca167 commit a4bbd6e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
25 changes: 13 additions & 12 deletions lib/pages/settings/notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:logging/logging.dart';
import 'package:provider/provider.dart';

import 'package:chopper/chopper.dart' show Response;
import 'package:device_apps/device_apps.dart';
import 'package:appcheck/appcheck.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:notifications_listener_service/notifications_listener_service.dart';

Expand Down Expand Up @@ -173,18 +173,18 @@ class _SettingsNotificationsState extends State<SettingsNotifications> {
onTap: () async {
final SettingsProvider settings =
context.read<SettingsProvider>();
Application? app = await showDialog<Application>(
AppInfo? app = await showDialog<AppInfo>(
context: context,
builder: (BuildContext context) => const AppDialog(),
);
if (app == null || app.packageName.isEmpty) {
if (app == null || app.appName == null) {
return;
}

await settings.notificationAddUsedApp(app.packageName);
await settings.notificationSetAppSettings(
app.packageName,
NotificationAppSettings(app.appName),
NotificationAppSettings(app.appName!),
);
setState(() {});
},
Expand Down Expand Up @@ -453,26 +453,27 @@ class AppDialogEntry extends StatelessWidget {
Widget build(BuildContext context) {
final Logger log = Logger("Notifications.AppDialog.Entry");

return FutureBuilder<Application?>(
future: DeviceApps.getApp(app, true),
builder: (BuildContext context, AsyncSnapshot<Application?> snapshot) {
return FutureBuilder<AppInfo?>(
future: AppCheck().checkAvailability(app),
builder: (BuildContext context, AsyncSnapshot<AppInfo?> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
if (snapshot.data == null || snapshot.data!.appName == null) {
return const SizedBox.shrink();
}
late Widget leading;
try {
final ApplicationWithIcon appIcon =
snapshot.data! as ApplicationWithIcon;
leading = Image.memory(appIcon.icon);
if (snapshot.data!.icon == null) {
throw Exception(); // will be caught below
}
leading = Image.memory(snapshot.data!.icon!);
} catch (e) {
leading = const Icon(Icons.api);
}
return ListTile(
leading: CircleAvatar(
child: leading,
),
title: Text(snapshot.data!.appName),
title: Text(snapshot.data!.appName!),
subtitle: Text(app),
onTap: () {
Navigator.pop(context, snapshot.data);
Expand Down
17 changes: 9 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
appcheck:
dependency: "direct main"
description:
path: "."
ref: ce371398f86412a8d9a2e0b75a9b51597ea1d79f
resolved-ref: ce371398f86412a8d9a2e0b75a9b51597ea1d79f
url: "https://github.com/bugrevealingbme/AppCheck.git"
source: git
version: "1.5.2"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -270,14 +279,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.10"
device_apps:
dependency: "direct main"
description:
name: device_apps
sha256: e84dc74d55749993fd671148cc0bd53096e1be0c268fc364285511b1d8a4c19b
url: "https://pub.dev"
source: hosted
version: "2.2.0"
dynamic_color:
dependency: "direct main"
description:
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ dependencies:
git:
url: https://github.com/dreautall/notification_listener_service.git
ref: 5f0d49d1b133943a6e6449059712514bf6506fd1
device_apps: ^2.2.0
appcheck:
git:
url: https://github.com/bugrevealingbme/AppCheck.git
ref: ce371398f86412a8d9a2e0b75a9b51597ea1d79f
package_info_plus: ^8.0.2
logging: ^1.1.1
flutter_email_sender: ^6.0.2
Expand Down

0 comments on commit a4bbd6e

Please sign in to comment.