vortitu il y a 5 ans
Parent
révision
32c500dce0
7 fichiers modifiés avec 114 ajouts et 157 suppressions
  1. +13
    -0
      .vscode/launch.json
  2. +1
    -1
      android/app/build.gradle
  3. +7
    -0
      android/app/src/main/AndroidManifest.xml
  4. +49
    -89
      lib/main.dart
  5. +8
    -0
      lib/notification_listen.dart
  6. +33
    -67
      pubspec.lock
  7. +3
    -0
      pubspec.yaml

+ 13
- 0
.vscode/launch.json Voir le fichier

@@ -0,0 +1,13 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "vortifier_app",
"request": "launch",
"type": "dart"
}
]
}

+ 1
- 1
android/app/build.gradle Voir le fichier

@@ -39,7 +39,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.vortifier_app"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName


+ 7
- 0
android/app/src/main/AndroidManifest.xml Voir le fichier

@@ -26,5 +26,12 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<service android:name="com.emilecode.android_notification_listener2.NotificationListener"
android:label="notifications"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
</application>
</manifest>

+ 49
- 89
lib/main.dart Voir le fichier

@@ -1,111 +1,71 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';

import 'package:android_notification_listener2/android_notification_listener2.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
class MyApp extends StatefulWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
_MyAppState createState() => _MyAppState();
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
class _MyAppState extends State<MyApp> {
AndroidNotificationListener _notifications;
StreamSubscription<NotificationEventV2> _subscription;

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
@override
void initState() {
super.initState();
initPlatformState();
}

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
startListening();
}

final String title;
void onData(NotificationEventV2 event) {
// const _packageToSearch = 'com.nianticproject.ingress';
// const _packageToSearch = 'com.enlnf';
const _packageToSearch = 'org.kman.AquaMail';

@override
_MyHomePageState createState() => _MyHomePageState();
}
print(event);
print(event.packageName);

if (event.packageName == _packageToSearch) {
print('INGRESS Notification');
print('INGRESS Notification');
print('INGRESS Notification');
}

print('converting package extra to json');
var jsonDatax = json.decode(event.packageExtra);
print(jsonDatax);
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void startListening() {
_notifications = new AndroidNotificationListener();
try {
_subscription = _notifications.notificationStream.listen(onData);
} on NotificationExceptionV2 catch (exception) {
print(exception);
}
}

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
void stopListening() {
_subscription.cancel();
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

+ 8
- 0
lib/notification_listen.dart Voir le fichier

@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';

class NotifiyListen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}

+ 33
- 67
pubspec.lock Voir le fichier

@@ -1,62 +1,55 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
args:
dependency: transitive
android_notification_listener2:
dependency: "direct main"
description:
name: args
name: android_notification_listener2
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "2.0.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
charcode:
version: "2.0.0"
characters:
dependency: transitive
description:
name: charcode
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
version: "1.0.0"
charcode:
dependency: transitive
description:
name: collection
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
version: "1.1.3"
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.0.1"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "1.14.13"
cupertino_icons:
dependency: "direct main"
description:
@@ -64,6 +57,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
@@ -74,20 +74,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.8"
meta:
dependency: transitive
description:
@@ -101,28 +94,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "1.7.0"
sky_engine:
dependency: transitive
description: flutter
@@ -134,14 +106,14 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
@@ -169,14 +141,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.2.0"
vector_math:
dependency: transitive
description:
@@ -184,12 +156,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.10.0"

+ 3
- 0
pubspec.yaml Voir le fichier

@@ -20,6 +20,9 @@ dependencies:
flutter:
sdk: flutter

# Notiffictions
android_notification_listener2: ^2.0.1

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2


Chargement…
Annuler
Enregistrer