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

[device_info_plus] Add TizenDeviceInfo.data property #590

Merged
merged 2 commits into from
Nov 28, 2023
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
5 changes: 4 additions & 1 deletion packages/device_info_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## NEXT
## 1.2.0

* Add `TizenDeviceInfo.data` which represents the device info as a map.
* Disambiguate the method channel name.
* Increase the minimum Flutter version to 3.3.
* Update the example app and integration_test.

## 1.1.0

Expand Down
8 changes: 4 additions & 4 deletions packages/device_info_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Add `device_info_plus_tizen` as a dependency in your `pubspec.yaml` file.

```yaml
dependencies:
device_info_plus_tizen: ^1.1.0
device_info_plus_tizen: ^1.2.0
```

Then you can import `device_info_plus_tizen` in your Dart code.
Expand All @@ -24,9 +24,9 @@ TizenDeviceInfo tizenInfo = await deviceInfo.tizenInfo;
String modelName = tizenInfo.modelName;
```

## Available values
## Supported properties

| Value | Feature or system key |
| Property | Feature or system key |
|-|-|
| `modelName` | `http://tizen.org/system/model_name` |
| `cpuArch` | `http://tizen.org/feature/platform.core.cpu.arch` |
Expand All @@ -47,4 +47,4 @@ String modelName = tizenInfo.modelName;
| `platformProcessor` | `http://tizen.org/system/platform.processor` |
| `tizenId` | `http://tizen.org/system/tizenid` |

For description on each feature or system key in the list, see https://docs.tizen.org/application/native/guides/device/system.
For a description of each feature or system key in the list, see https://docs.tizen.org/application/native/guides/device/system.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:flutter_test/flutter_test.dart';
import 'package:device_info_plus_tizen/device_info_plus_tizen.dart';
import 'package:integration_test/integration_test.dart';
Expand All @@ -19,4 +21,26 @@ void main() {
testWidgets('Can get non-null device model', (WidgetTester tester) async {
expect(tizenInfo.modelName, isNotNull);
});

testWidgets('Check all Tizen info values are available',
(WidgetTester tester) async {
expect(tizenInfo.modelName, isNotNull);
expect(tizenInfo.cpuArch, isNotNull);
expect(tizenInfo.nativeApiVersion, isNotNull);
expect(tizenInfo.platformVersion, isNotNull);
expect(tizenInfo.webApiVersion, isNotNull);
expect(tizenInfo.profile, isNotNull);
expect(tizenInfo.buildDate, isNotNull);
expect(tizenInfo.buildId, isNotNull);
expect(tizenInfo.buildString, isNotNull);
expect(tizenInfo.buildTime, isNotNull);
expect(tizenInfo.buildType, isNotNull);
expect(tizenInfo.buildVariant, isNotNull);
expect(tizenInfo.buildRelease, isNotNull);
expect(tizenInfo.deviceType, isNotNull);
expect(tizenInfo.manufacturer, isNotNull);
expect(tizenInfo.platformName, isNotNull);
expect(tizenInfo.platformProcessor, isNotNull);
expect(tizenInfo.tizenId, isNotNull);
}, skip: !Platform.isLinux);
}
28 changes: 18 additions & 10 deletions packages/device_info_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
Expand Down Expand Up @@ -80,15 +80,22 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: const Color(0x9f4376f8),
),
home: Scaffold(
appBar: AppBar(title: const Text('Tizen Device Info')),
appBar: AppBar(
title: const Text('Tizen Device Info'),
elevation: 4,
),
body: ListView(
children: _deviceData.keys.map(
(String property) {
return Row(
children: <Widget>[
Container(
padding: const EdgeInsets.all(10.0),
padding: const EdgeInsets.all(10),
child: Text(
property,
style: const TextStyle(
Expand All @@ -97,14 +104,15 @@ class _MyAppState extends State<MyApp> {
),
),
Expanded(
child: Container(
padding: const EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0),
child: Text(
'${_deviceData[property]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
'${_deviceData[property]}',
maxLines: 10,
overflow: TextOverflow.ellipsis,
),
),
)),
),
],
);
},
Expand Down
1 change: 0 additions & 1 deletion packages/device_info_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dev_dependencies:
sdk: flutter
integration_test_tizen:
path: ../../integration_test/
flutter_lints: ^1.0.4

flutter:
uses-material-design: true
27 changes: 24 additions & 3 deletions packages/device_info_plus/lib/device_info_plus_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class TizenDeviceInfo {
/// http://tizen.org/system/tizenid
final String? tizenId;

/// Deserializes from the message received from [_kChannel].
/// Creates a [TizenDeviceInfo] from the [map].
static TizenDeviceInfo fromMap(Map<String, dynamic> map) {
return TizenDeviceInfo(
modelName: map['modelName'],
Expand All @@ -109,12 +109,33 @@ class TizenDeviceInfo {
tizenId: map['tizenId'],
);
}

/// Device information data.
Map<String, dynamic> get data => {
'modelName': modelName,
'cpuArch': cpuArch,
'nativeApiVersion': nativeApiVersion,
'platformVersion': platformVersion,
'webApiVersion': webApiVersion,
'profile': profile,
'buildDate': buildDate,
'buildId': buildId,
'buildString': buildString,
'buildTime': buildTime,
'buildType': buildType,
'buildVariant': buildVariant,
'buildRelease': buildRelease,
'deviceType': deviceType,
'manufacturer': manufacturer,
'platformName': platformName,
'platformProcessor': platformProcessor,
'tizenId': tizenId,
};
JSUYA marked this conversation as resolved.
Show resolved Hide resolved
}

class _MethodChannelDeviceInfo {
/// The method channel used to interact with the native platform.
MethodChannel channel =
const MethodChannel('dev.fluttercommunity.plus/device_info');
MethodChannel channel = const MethodChannel('tizen/device_info_plus');

/// Method channel for Tizen devices.
Future<TizenDeviceInfo> tizenInfo() async {
Expand Down
6 changes: 3 additions & 3 deletions packages/device_info_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: device_info_plus_tizen
description: Flutter plugin providing detailed information about Tizen device
(make, model, etc.).
(make, model, etc.) the app is running on.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/device_info_plus
version: 1.1.0
version: 1.2.0

environment:
sdk: ">=2.18.0 <4.0.0"
Expand All @@ -21,4 +21,4 @@ dependencies:
sdk: flutter

dev_dependencies:
flutter_lints: ^1.0.4
flutter_lints: ^2.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DeviceInfoPlusTizenPlugin : public flutter::Plugin {
static void RegisterWithRegistrar(flutter::PluginRegistrar *registrar) {
auto channel =
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
registrar->messenger(), "dev.fluttercommunity.plus/device_info",
registrar->messenger(), "tizen/device_info_plus",
&flutter::StandardMethodCodec::GetInstance());

auto plugin = std::make_unique<DeviceInfoPlusTizenPlugin>();
Expand Down