Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions packages/connectivity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
3 changes: 3 additions & 0 deletions packages/connectivity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release
26 changes: 26 additions & 0 deletions packages/connectivity/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
Copyright (c) 2017 The Chromium Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the names of the copyright holders nor the names of the
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 changes: 36 additions & 0 deletions packages/connectivity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# connectivity_tizen

The Tizen implementation of [`connectivity`](https://github.com/flutter/plugins/tree/master/packages/connectivity).

## Usage

This package is not an _endorsed_ implementation of `connectivity`. Therefore, you have to include `connectivity_tizen` alongside `connectivity` as dependencies in your `pubspec.yaml` file.

```yaml
dependencies:
connectivity: ^2.0.2
connectivity_tizen: ^1.0.0
```
Then you can import `connectivity` in your Dart code:

```dart
import 'package:connectivity/connectivity.dart';
```

For detailed usage, see https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity#usage.

## Supported devices

This plugin is supported on these types of devices:

- Galaxy Watch (running Tizen 4.0 or later)
Copy link
Member

Choose a reason for hiding this comment

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

Please specify if any privilege is required to use this plugin in README. There's an example in the checklist or https://github.com/flutter-tizen/plugins/tree/master/packages/path_provider#required-privileges.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

Just a nitpick but it would be better to remove the bullet (-) and indentation since they are redundant.


## Required privileges

To get connectivity information using this plugin, add below lines under the `<manifest>` section in your `tizen-manifest.xml` file,

```xml
<privileges>
<privilege>http://tizen.org/privilege/network.get</privilege>
</privileges>
```
41 changes: 41 additions & 0 deletions packages/connectivity/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
7 changes: 7 additions & 0 deletions packages/connectivity/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# connectiviy example

Demonstrates how to use the connectiviy plugin.

## Getting Started

To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:connectivity/connectivity.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('Connectivity test driver', () {
Connectivity _connectivity;

setUpAll(() async {
_connectivity = Connectivity();
});

testWidgets('test connectivity result', (WidgetTester tester) async {
final ConnectivityResult result = await _connectivity.checkConnectivity();
expect(result, isNotNull);
});
});
}
112 changes: 112 additions & 0 deletions packages/connectivity/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// 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 'dart:async';
import 'dart:io';

import 'package:connectivity/connectivity.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

// Sets a platform override for desktop to avoid exceptions. See
// https://flutter.dev/desktop#target-platform-override for more info.
void _enablePlatformOverrideForDesktop() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
}

void main() {
_enablePlatformOverrideForDesktop();
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
String _connectionStatus = 'Unknown';
final Connectivity _connectivity = Connectivity();
StreamSubscription<ConnectivityResult> _connectivitySubscription;

@override
void initState() {
super.initState();
initConnectivity();
_connectivitySubscription =
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
}

@override
void dispose() {
_connectivitySubscription.cancel();
super.dispose();
}

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initConnectivity() async {
ConnectivityResult result;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
result = await _connectivity.checkConnectivity();
} on PlatformException catch (e) {
print(e.toString());
}

// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) {
return Future.value(null);
}

return _updateConnectionStatus(result);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Connectivity example app'),
),
body: Center(child: Text('Connection Status: $_connectionStatus')),
);
}

Future<void> _updateConnectionStatus(ConnectivityResult result) async {
switch (result) {
case ConnectivityResult.wifi:
case ConnectivityResult.mobile:
case ConnectivityResult.none:
setState(() => _connectionStatus = result.toString());
break;
default:
setState(() => _connectionStatus = 'Failed to get connectivity.');
break;
}
}
}
22 changes: 22 additions & 0 deletions packages/connectivity/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: connectivity_example
description: Demonstrates how to use the connectivity plugin.
publish_to: 'none'

dependencies:
flutter:
sdk: flutter
connectivity: ^2.0.2
connectivity_tizen:
path: ../

dev_dependencies:
flutter_driver:
sdk: flutter
test: any
pedantic: ^1.8.0
integration_test: ^1.0.1
integration_test_tizen:
path: ../../integration_test/

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
5 changes: 5 additions & 0 deletions packages/connectivity/example/tizen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flutter/
.vs/
*.user
bin/
obj/
20 changes: 20 additions & 0 deletions packages/connectivity/example/tizen/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Tizen.Flutter.Embedding;

namespace Runner
{
public class App : FlutterApplication
{
protected override void OnCreate()
{
base.OnCreate();

GeneratedPluginRegistrant.RegisterPlugins(this);
}

static void Main(string[] args)
{
var app = new App();
app.Run(args);
}
}
}
7 changes: 7 additions & 0 deletions packages/connectivity/example/tizen/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="tizen.myget.org" value="https://tizen.myget.org/F/dotnet/api/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
26 changes: 26 additions & 0 deletions packages/connectivity/example/tizen/Runner.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Tizen.NET.Sdk/1.1.5">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>tizen40</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Tizen.Flutter.Embedding" Version="$(FlutterEmbeddingVersion)" />
</ItemGroup>

<ItemGroup>
<FlutterEphemeral Include="flutter\ephemeral\**\*" />
<TizenTpkUserIncludeFiles Include="@(FlutterEphemeral)">
<TizenTpkSubDir>%(RecursiveDir)</TizenTpkSubDir>
</TizenTpkUserIncludeFiles>
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/connectivity/example/tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.tizen.connectivity_tizen_example" version="1.0.0" api-version="4.0" xmlns="http://tizen.org/ns/packages">
<profile name="common"/>
<ui-application appid="org.tizen.connectivity_tizen_example" exec="Runner.dll" type="dotnet" multiple="false" taskmanage="true" nodisplay="false" api-version="4" launch_mode="single">
<label>connectivity_tizen_example</label>
<icon>ic_launcher.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
<metadata key="http://tizen.org/metadata/direct-launch" value="yes"/>
</ui-application>
<feature name="http://tizen.org/feature/screen.size.all"/>
<privileges>
<privilege>http://tizen.org/privilege/network.get</privilege>
</privileges>
</manifest>
28 changes: 28 additions & 0 deletions packages/connectivity/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: connectivity_tizen
description: Flutter plugin for discovering the state of the network (WiFi) connectivity on Tizen.
version: 1.0.0
homepage: https://github.com/flutter-tizen/plugins

flutter:
plugin:
platforms:
tizen:
pluginClass: ConnectivityTizenPlugin
fileName: connectivity_tizen_plugin.h
dependencies:
connectivity: ^2.0.2
connectivity_platform_interface: ^1.0.6
flutter:
sdk: flutter

dev_dependencies:
test: any
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
mockito: ^4.1.1

environment:
sdk: ">=2.6.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4"
Loading