Skip to content

Commit 5a898a3

Browse files
authored
[tizen_notification] Bump version to 0.2.0 (#481)
1 parent 56bc19f commit 5a898a3

File tree

8 files changed

+527
-584
lines changed

8 files changed

+527
-584
lines changed

packages/tizen_notification/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.2.0
2+
3+
* Clean up the API.
4+
* Rename `NotificationImage` to `NotificationIcons`.
5+
* Rename `Property` to `NotificationProperty`.
6+
* Rename `DisplayApplist` to `NotificationStyle`.
7+
* Rename some members of the above classes.
8+
* Update the documentation.
9+
* Code refactoring and bug fixes.
10+
111
## 0.1.1
212

313
* Update the example app.

packages/tizen_notification/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Tizen notification APIs. Used to show and delete notifications on a Tizen device
66

77
## Usage
88

9-
To use this plugin, add `tizen_notification` as a dependency in your pubspec.yaml file:
9+
To use this plugin, add `tizen_notification` as a dependency in your `pubspec.yaml` file:
1010

1111
```yaml
1212
dependencies:
13-
tizen_notification: ^0.1.1
13+
tizen_notification: ^0.2.0
1414
```
1515
1616
Then you can import `tizen_notification` in your Dart code:

packages/tizen_notification/example/lib/main.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@ class MyApp extends StatelessWidget {
1616

1717
final TizenNotificationPlugin _tizenNotificationPlugin =
1818
TizenNotificationPlugin();
19-
final int notificationId = 1;
19+
final int _notificationId = 1;
2020

2121
Future<void> _showNotification() async {
2222
final TizenNotificationDetails details = TizenNotificationDetails(
23-
image: NotificationImage(iconPath: 'test.png'),
24-
properties: Property.disableAutoDelete | Property.disableAppLaunch,
25-
vibration: NotificationVibration(type: VibrationType.builtIn),
23+
icons: NotificationIcons(icon: 'test.png'),
2624
sound: NotificationSound(type: SoundType.builtIn),
25+
vibration: NotificationVibration(type: VibrationType.builtIn),
26+
properties: NotificationProperty.disableAutoDelete,
27+
appControl: AppControl(appId: 'org.tizen.tizen_notification_example'),
2728
);
2829
await _tizenNotificationPlugin.show(
29-
notificationId,
30-
title: 'show Notification Title',
31-
body: 'show Notification Body',
30+
_notificationId,
31+
title: 'Notification title',
32+
body: 'Notification body',
3233
notificationDetails: details,
3334
);
3435
}
3536

3637
Future<void> _cancelNotification() async {
37-
await _tizenNotificationPlugin.cancel(notificationId);
38+
await _tizenNotificationPlugin.cancel(_notificationId);
3839
}
3940

4041
Future<void> _cancelAllNotifications() async {
@@ -45,6 +46,7 @@ class MyApp extends StatelessWidget {
4546
Widget build(BuildContext context) {
4647
return MaterialApp(
4748
home: Scaffold(
49+
appBar: AppBar(title: const Text('Tizen Notification Example')),
4850
body: Center(
4951
child: Column(
5052
mainAxisAlignment: MainAxisAlignment.center,
@@ -53,10 +55,12 @@ class MyApp extends StatelessWidget {
5355
onPressed: _showNotification,
5456
child: const Text('Show notification'),
5557
),
58+
const SizedBox(height: 10),
5659
ElevatedButton(
5760
onPressed: _cancelNotification,
5861
child: const Text('Cancel notification'),
5962
),
63+
const SizedBox(height: 10),
6064
ElevatedButton(
6165
onPressed: _cancelAllNotifications,
6266
child: const Text('Cancel all notifications'),

packages/tizen_notification/lib/src/enums.dart

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/tizen_notification/lib/src/types.dart

Lines changed: 158 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,199 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// ignore_for_file: public_member_api_docs
5+
import 'package:tizen_app_control/tizen_app_control.dart';
66

7-
import 'enums.dart';
7+
export 'package:tizen_app_control/tizen_app_control.dart';
88

9-
/// Properties that configure how the system handles notification at
10-
/// certain scenarios.
11-
class Property {
12-
/// Display only SIM card inserted.
13-
static const int displayOnlySimMode = 1 << 0;
9+
/// How the system handles the notification in certain scenarios.
10+
class NotificationProperty {
11+
// The constants below are originally defined in notification_type.h as
12+
// the enum type _notification_property.
13+
NotificationProperty._();
1414

15-
/// Disable application launch when notification is selected.
16-
static const int disableAppLaunch = 1 << 1;
15+
/// Display only if a SIM card is inserted.
16+
static const int onlySimMode = 0x00000001;
1717

18-
/// Disable auto delete when notification is selected.
19-
static const int disableAutoDelete = 1 << 2;
18+
/// Do not perform any operation when the notification is clicked.
19+
static const int disableAppLaunch = 0x00000002;
2020

21-
/// Delete notification when device is rebooted.
22-
static const int volatileDisplay = 1 << 8;
21+
/// Do not dismiss the notification when clicked.
22+
static const int disableAutoDelete = 0x00000004;
23+
24+
/// Dismiss the notification when the device is rebooted.
25+
static const int volatile = 0x00000100;
2326
}
2427

25-
/// The destination app that displays notification.
26-
class DisplayApplist {
27-
/// Notification Tray(Quickpanel).
28-
static const int tray = 1 << 0;
28+
/// Where and how the notification should be presented.
29+
class NotificationStyle {
30+
// The constants below are originally defined in notification_type.h as
31+
// the enum type _notification_display_applist.
32+
NotificationStyle._();
2933

30-
/// Ticker notification.
31-
static const int ticker = 1 << 1;
34+
/// Display in the notification area of the quick panel.
35+
static const int tray = 0x00000001;
3236

33-
/// Lock screen.
34-
static const int lock = 1 << 2;
37+
/// Display in the lock screen.
38+
static const int lock = 0x00000004;
3539

36-
/// Indicator.
37-
static const int indicator = 1 << 3;
40+
/// Display in the indicator area (the top of the screen).
41+
static const int indicator = 0x00000002 | 0x00000008;
3842

39-
/// All display application.
40-
static const int all = (1 << 4) - 1;
43+
/// All of the above.
44+
static const int all = tray | lock | indicator;
4145
}
4246

43-
class NotificationImage {
44-
/// [NotificationImage] specifies image options for notifications.
45-
NotificationImage({
46-
this.iconPath,
47-
this.indicatorPath,
48-
this.lockPath,
47+
/// A set of icons to be shown in the notification layouts.
48+
class NotificationIcons {
49+
/// Creates a [NotificationIcons] with the given icon paths.
50+
NotificationIcons({
51+
this.icon,
52+
this.indicatorIcon,
53+
this.lockIcon,
4954
});
5055

51-
/// The path of icon.
52-
final String? iconPath;
56+
/// The path to the icon file.
57+
String? icon;
5358

54-
/// The path of indicator icon.
55-
final String? indicatorPath;
59+
/// The path to the indicator icon file.
60+
String? indicatorIcon;
5661

57-
/// The path of lock screen icon.
58-
final String? lockPath;
62+
/// The path to the lock screen icon file.
63+
String? lockIcon;
5964

60-
/// Returns [NotificationImage] member fields in a map format.
61-
Map<String, dynamic> toMap() => <String, dynamic>{
62-
'icon': iconPath,
63-
'iconForIndicator': indicatorPath,
64-
'iconForLock': lockPath,
65+
/// Converts to a map.
66+
Map<String, String?> toMap() => <String, String?>{
67+
'icon': icon,
68+
'iconForIndicator': indicatorIcon,
69+
'iconForLock': lockIcon,
6570
};
6671
}
6772

73+
/// The type of sound.
74+
enum SoundType {
75+
/// No sound.
76+
none,
77+
78+
/// Default sound.
79+
builtIn,
80+
81+
/// User sound data.
82+
userData,
83+
}
84+
85+
/// The sound to play when the notification is presented.
6886
class NotificationSound {
69-
/// [NotificationSound] specifies sound options for notifications.
70-
///
71-
/// [path] refers to a file path to custom sound data played on notification,
72-
/// this value is ignored When [type] is not [SoundType.userData].
73-
NotificationSound({
74-
required this.type,
75-
this.path,
76-
});
87+
/// Creates a [NotificationSound] with the given [type] and [path].
88+
NotificationSound({required this.type, this.path});
89+
90+
/// The type of sound.
91+
SoundType type;
7792

78-
final SoundType type;
93+
/// The path to the user sound data file.
94+
///
95+
/// Only applicable if the [type] is [SoundType.userData].
7996
String? path;
8097

81-
/// Returns [NotificationSound] member fields in a map format.
82-
Map<String, dynamic> toMap() => <String, dynamic>{
98+
/// Converts to a map.
99+
Map<String, String?> toMap() => <String, String?>{
83100
'type': type.name,
84101
'path': path,
85102
};
86103
}
87104

105+
/// The type of vibration.
106+
enum VibrationType {
107+
/// No vibration.
108+
none,
109+
110+
/// Default vibration pattern.
111+
builtIn,
112+
113+
/// User vibration data.
114+
userData,
115+
}
116+
117+
/// The notification vibration options.
88118
class NotificationVibration {
89-
/// [NotificationVibration] specifies vibration options for notifications.
90-
NotificationVibration({
91-
required this.type,
92-
this.path,
93-
});
119+
/// Creates a [NotificationVibration] with the given [type] and [path].
120+
NotificationVibration({required this.type, this.path});
94121

95-
final VibrationType type;
122+
/// The type of vibration.
123+
VibrationType type;
124+
125+
/// The path to the user vibration data file.
126+
///
127+
/// Only applicable if the [type] is [VibrationType.userData].
96128
String? path;
97129

98-
/// Returns [NotificationVibration] member fields in a map format.
99-
Map<String, dynamic> toMap() => <String, dynamic>{
130+
/// Converts to a map.
131+
Map<String, String?> toMap() => <String, String?>{
100132
'type': type.name,
101133
'path': path,
102134
};
103135
}
136+
137+
extension _AppControlToMap on AppControl {
138+
/// Converts to a map.
139+
Map<String, Object?> toMap() => <String, Object?>{
140+
'appId': appId,
141+
'operation': operation,
142+
'uri': uri,
143+
'mime': mime,
144+
'extraData': extraData,
145+
};
146+
}
147+
148+
/// The notification details.
149+
class TizenNotificationDetails {
150+
/// Constructs a [TizenNotificationDetails] from the given properties.
151+
TizenNotificationDetails({
152+
this.icons,
153+
this.sound,
154+
this.vibration,
155+
this.properties = 0,
156+
this.style = NotificationStyle.all,
157+
this.ongoing = false,
158+
this.appControl,
159+
});
160+
161+
/// A set of icons to be shown in the notification layouts.
162+
NotificationIcons? icons;
163+
164+
/// The sound to play when the notification is presented.
165+
NotificationSound? sound;
166+
167+
/// The notification vibration options.
168+
NotificationVibration? vibration;
169+
170+
/// Specifies how the system handles the notification in certain scenarios.
171+
///
172+
/// Multiple [NotificationProperty] values can be set using the bitwise OR
173+
/// operator (|).
174+
int properties;
175+
176+
/// Specifies where and how the notification should be presented.
177+
///
178+
/// Multiple [NotificationStyle] values can be set using the bitwise OR
179+
/// operator (|).
180+
int style;
181+
182+
/// Whether the notification can be dismissed by user.
183+
///
184+
/// Only supported on Raspberry Pi (common profile) devices.
185+
bool ongoing;
186+
187+
/// A control message to be sent when the notification is clicked.
188+
AppControl? appControl;
189+
190+
/// Converts to a map.
191+
Map<String, Object?> toMap() => <String, Object?>{
192+
'image': icons?.toMap(),
193+
'sound': sound?.toMap(),
194+
'vibration': vibration?.toMap(),
195+
'properties': properties,
196+
'displayApplist': style,
197+
'ongoing': ongoing,
198+
'appControl': appControl?.toMap(),
199+
};
200+
}

0 commit comments

Comments
 (0)