Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tizen_notification] Bump version to 0.2.0 #481

Merged
merged 5 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions packages/tizen_notification/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.2.0

* Clean up the API.
* Rename `NotificationImage` to `NotificationIcons`.
* Rename `Property` to `NotificationProperty`.
* Rename `DisplayApplist` to `NotificationStyle`.
* Rename some members of the above classes.
* Update the documentation.
* Code refactoring and bug fixes.

## 0.1.1

* Update the example app.
Expand Down
4 changes: 2 additions & 2 deletions packages/tizen_notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Tizen notification APIs. Used to show and delete notifications on a Tizen device

## Usage

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

```yaml
dependencies:
tizen_notification: ^0.1.1
tizen_notification: ^0.2.0
```

Then you can import `tizen_notification` in your Dart code:
Expand Down
20 changes: 12 additions & 8 deletions packages/tizen_notification/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ class MyApp extends StatelessWidget {

final TizenNotificationPlugin _tizenNotificationPlugin =
TizenNotificationPlugin();
final int notificationId = 1;
final int _notificationId = 1;

Future<void> _showNotification() async {
final TizenNotificationDetails details = TizenNotificationDetails(
image: NotificationImage(iconPath: 'test.png'),
properties: Property.disableAutoDelete | Property.disableAppLaunch,
vibration: NotificationVibration(type: VibrationType.builtIn),
icons: NotificationIcons(icon: 'test.png'),
sound: NotificationSound(type: SoundType.builtIn),
vibration: NotificationVibration(type: VibrationType.builtIn),
properties: NotificationProperty.disableAutoDelete,
appControl: AppControl(appId: 'org.tizen.tizen_notification_example'),
);
await _tizenNotificationPlugin.show(
notificationId,
title: 'show Notification Title',
body: 'show Notification Body',
_notificationId,
title: 'Notification title',
body: 'Notification body',
notificationDetails: details,
);
}

Future<void> _cancelNotification() async {
await _tizenNotificationPlugin.cancel(notificationId);
await _tizenNotificationPlugin.cancel(_notificationId);
}

Future<void> _cancelAllNotifications() async {
Expand All @@ -45,6 +46,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Tizen Notification Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -53,10 +55,12 @@ class MyApp extends StatelessWidget {
onPressed: _showNotification,
child: const Text('Show notification'),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: _cancelNotification,
child: const Text('Cancel notification'),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: _cancelAllNotifications,
child: const Text('Cancel all notifications'),
Expand Down
27 changes: 0 additions & 27 deletions packages/tizen_notification/lib/src/enums.dart

This file was deleted.

197 changes: 142 additions & 55 deletions packages/tizen_notification/lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,189 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs
import 'package:tizen_app_control/tizen_app_control.dart';

import 'enums.dart';
export 'package:tizen_app_control/tizen_app_control.dart';

/// Properties that configure how the system handles notification at
/// certain scenarios.
class Property {
/// Display only SIM card inserted.
static const int displayOnlySimMode = 1 << 0;
/// How the system handles the notification in certain scenarios.
class NotificationProperty {
bbrto21 marked this conversation as resolved.
Show resolved Hide resolved
/// Display only if a SIM card is inserted.
static const int onlySimMode = 1 << 0;

/// Disable application launch when notification is selected.
/// Do not perform any operation when the notification is clicked.
static const int disableAppLaunch = 1 << 1;

/// Disable auto delete when notification is selected.
/// Do not dismiss the notification when clicked.
static const int disableAutoDelete = 1 << 2;

/// Delete notification when device is rebooted.
static const int volatileDisplay = 1 << 8;
/// Dismiss the notification when the device is rebooted.
static const int volatile = 1 << 8;
}

/// The destination app that displays notification.
class DisplayApplist {
/// Notification Tray(Quickpanel).
/// Where and how the notification should be presented.
class NotificationStyle {
/// Display in the notification area of the quick panel.
static const int tray = 1 << 0;

/// Ticker notification.
static const int ticker = 1 << 1;

/// Lock screen.
/// Display in the lock screen.
static const int lock = 1 << 2;

/// Indicator.
static const int indicator = 1 << 3;
/// Display in the indicator area (the top of the screen).
static const int indicator = 1 << 1 | 1 << 3;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTIFICATION_DISPLAY_APP_TICKER and NOTIFICATION_DISPLAY_APP_INDICATOR do not work in the way they are documented and now they are a single property.

  • NOTIFICATION_DISPLAY_APP_INDICATOR has no effect on mobile (only NOTIFICATION_DISPLAY_APP_TICKER works in an unexpected way).
  • NOTIFICATION_DISPLAY_APP_TICKER is effectively the same as NOTIFICATION_DISPLAY_APP_INDICATOR on RPi.


/// All display application.
/// All of the above.
static const int all = (1 << 4) - 1;
bbrto21 marked this conversation as resolved.
Show resolved Hide resolved
}

class NotificationImage {
/// [NotificationImage] specifies image options for notifications.
NotificationImage({
this.iconPath,
this.indicatorPath,
this.lockPath,
/// A set of icons to be shown in the notification layouts.
class NotificationIcons {
/// Creates a [NotificationIcons] with the given icon paths.
NotificationIcons({
this.icon,
this.indicatorIcon,
this.lockIcon,
});

/// The path of icon.
final String? iconPath;
/// The path to the icon file.
final String? icon;

/// The path of indicator icon.
final String? indicatorPath;
/// The path to the indicator icon file.
final String? indicatorIcon;

/// The path of lock screen icon.
final String? lockPath;
/// The path to the lock screen icon file.
final String? lockIcon;

/// Returns [NotificationImage] member fields in a map format.
Map<String, dynamic> toMap() => <String, dynamic>{
'icon': iconPath,
'iconForIndicator': indicatorPath,
'iconForLock': lockPath,
/// Converts to a map.
Map<String, Object?> toMap() => <String, Object?>{
bbrto21 marked this conversation as resolved.
Show resolved Hide resolved
'icon': icon,
'iconForIndicator': indicatorIcon,
'iconForLock': lockIcon,
};
}

/// The type of sound.
enum SoundType {
/// No sound.
none,

/// Default sound.
builtIn,

/// User sound data.
userData,
}

/// The sound to play when the notification is presented.
class NotificationSound {
/// [NotificationSound] specifies sound options for notifications.
///
/// [path] refers to a file path to custom sound data played on notification,
/// this value is ignored When [type] is not [SoundType.userData].
NotificationSound({
required this.type,
this.path,
});
/// Creates a [NotificationSound] with the given [type] and [path].
NotificationSound({required this.type, this.path});

/// The type of sound.
final SoundType type;

/// The path to the user sound data file.
///
/// Only applicable if the [type] is [SoundType.userData].
String? path;

/// Returns [NotificationSound] member fields in a map format.
Map<String, dynamic> toMap() => <String, dynamic>{
/// Converts to a map.
Map<String, Object?> toMap() => <String, Object?>{
'type': type.name,
'path': path,
};
}

/// The type of vibration.
enum VibrationType {
/// No vibration.
none,

/// Default vibration pattern.
builtIn,

/// User vibration data.
userData,
}

/// The notification vibration options.
class NotificationVibration {
/// [NotificationVibration] specifies vibration options for notifications.
NotificationVibration({
required this.type,
this.path,
});
/// Creates a [NotificationVibration] with the given [type] and [path].
NotificationVibration({required this.type, this.path});

/// The type of vibration.
final VibrationType type;

/// The path to the user vibration data file.
///
/// Only applicable if the [type] is [VibrationType.userData].
String? path;

/// Returns [NotificationVibration] member fields in a map format.
Map<String, dynamic> toMap() => <String, dynamic>{
/// Converts to a map.
Map<String, Object?> toMap() => <String, Object?>{
'type': type.name,
bbrto21 marked this conversation as resolved.
Show resolved Hide resolved
'path': path,
};
}

/// The notification details.
class TizenNotificationDetails {
/// Constructs a [TizenNotificationDetails] from the given properties.
const TizenNotificationDetails({
this.icons,
this.sound,
this.vibration,
this.properties = 0,
this.style = NotificationStyle.all,
this.ongoing = false,
this.appControl,
});

/// A set of icons to be shown in the notification layouts.
final NotificationIcons? icons;

/// The sound to play when the notification is presented.
final NotificationSound? sound;

/// The notification vibration options.
final NotificationVibration? vibration;

/// Specifies how the system handles the notification in certain scenarios.
///
/// Multiple [NotificationProperty] values can be set using the bitwise OR
/// operator (|).
final int properties;

/// Specifies where and how the notification should be presented.
///
/// Multiple [NotificationStyle] values can be set using the bitwise OR
/// operator (|).
final int style;

/// Whether the notification can be dismissed by user.
///
/// Only supported on Raspberry Pi (common profile) devices.
final bool ongoing;

/// A control message to be sent when the notification is clicked.
final AppControl? appControl;

/// Converts to a map.
Map<String, Object?> toMap() => <String, Object?>{
'image': icons?.toMap(),
'sound': sound?.toMap(),
'vibration': vibration?.toMap(),
'properties': appControl != null
? properties
: properties | NotificationProperty.disableAppLaunch,
bbrto21 marked this conversation as resolved.
Show resolved Hide resolved
'displayApplist': style,
'ongoing': ongoing,
if (appControl != null)
'appControl': <String, Object?>{
'appId': appControl!.appId,
'operation': appControl!.operation,
'uri': appControl!.uri,
'mime': appControl!.mime,
'extraData': appControl!.extraData,
},
};
}
Loading