Skip to content

Commit

Permalink
[tizen_app_control]: Update example app type cpp to c#
Browse files Browse the repository at this point in the history
Now C# Multi type application is supported, so updated it.
  • Loading branch information
JSUYA committed Dec 22, 2023
1 parent dcbc02c commit 0f236e0
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 178 deletions.
54 changes: 5 additions & 49 deletions packages/tizen_app_control/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,11 @@ class _MyAppState extends State<MyApp> {
_localPort?.unregister();
}

Future<void> _sendSms() async {
Future<void> _openWeb() async {
final AppControl request = AppControl(
operation: 'http://tizen.org/appcontrol/operation/share_text',
uri: 'sms:',
operation: 'http://tizen.org/appcontrol/operation/view',
uri: 'https://flutter.dev/',
launchMode: LaunchMode.group,
extraData: <String, dynamic>{
'http://tizen.org/appcontrol/data/text': 'Some text',
},
);
final List<String> matches = await request.getMatchedAppIds();
if (matches.isEmpty) {
Expand All @@ -108,42 +105,6 @@ class _MyAppState extends State<MyApp> {
await request.sendLaunchRequest();
}

Future<void> _pickImage() async {
final AppControl request = AppControl(
operation: 'http://tizen.org/appcontrol/operation/pick',
mime: 'image/*',
launchMode: LaunchMode.group,
);
final List<String> matches = await request.getMatchedAppIds();
if (matches.isEmpty) {
_messengerKey.currentState!.showSnackBar(
const SnackBar(content: Text('No application found.')),
);
return;
}
await request.sendLaunchRequest(
replyCallback: (
AppControl request,
AppControl reply,
AppControlReplyResult result,
) {
const String kAppControlDataSelected =
'http://tizen.org/appcontrol/data/selected';
String? imagePath;
if (result == AppControlReplyResult.succeeded &&
reply.extraData.containsKey(kAppControlDataSelected)) {
final List<String> imagePaths =
(reply.extraData[kAppControlDataSelected] as List<Object?>)
.cast<String>();
imagePath = imagePaths[0];
}
_messengerKey.currentState!.showSnackBar(
SnackBar(content: Text(imagePath ?? 'No image selected.')),
);
},
);
}

Future<void> _launchService() async {
final AppControl request = AppControl(appId: _kServiceAppId);
await request.sendLaunchRequest(
Expand Down Expand Up @@ -184,13 +145,8 @@ class _MyAppState extends State<MyApp> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ElevatedButton(
onPressed: _sendSms,
child: const Text('Send SMS'),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: _pickImage,
child: const Text('Pick image'),
onPressed: _openWeb,
child: const Text('Open web page(https://flutter.dev/).'),
),
const SizedBox(height: 10),
if (_isServiceStarted)
Expand Down
5 changes: 0 additions & 5 deletions packages/tizen_app_control/example/tizen/service/.exportMap

This file was deleted.

13 changes: 5 additions & 8 deletions packages/tizen_app_control/example/tizen/service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
lib/*.so
res/flutter_assets/
res/icudtl.dat
.cproject
.sign
crash-info/
Debug/
Release/
flutter/
.vs/
*.user
bin/
obj/
21 changes: 21 additions & 0 deletions packages/tizen_app_control/example/tizen/service/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Tizen.Flutter.Embedding;

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

GeneratedPluginRegistrant.RegisterPlugins(this);
}

static void Main(string[] args)
{
var app = new App();
app.DartEntrypoint = "serviceMain";
app.Run(args);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Tizen.NET.Sdk/1.1.7">

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

<ItemGroup>
<ProjectReference Include="$(FlutterEmbeddingPath)" />
</ItemGroup>

</Project>
6 changes: 0 additions & 6 deletions packages/tizen_app_control/example/tizen/service/inc/runner.h

This file was deleted.

25 changes: 0 additions & 25 deletions packages/tizen_app_control/example/tizen/service/project_def.prop

This file was deleted.

Binary file not shown.
19 changes: 0 additions & 19 deletions packages/tizen_app_control/example/tizen/service/src/runner.cc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.tizen.tizen_app_control_example" version="1.0.0" api-version="5.5" xmlns="http://tizen.org/ns/packages">
<profile name="wearable"/>
<service-application appid="org.tizen.tizen_app_control_example_service" exec="runner_service" type="capp" multiple="false" nodisplay="true" taskmanage="false" auto-restart="false">
<profile name="common"/>
<service-application appid="org.tizen.tizen_app_control_example_service" exec="RunnerService.dll" type="dotnet" multiple="false" nodisplay="true" taskmanage="false" auto-restart="false">
<label>tizen_app_control_example</label>
<icon>ic_launcher.png</icon>
<background-category value="media"/>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
</service-application>
<feature name="http://tizen.org/feature/screen.size.all"/>
</manifest>
5 changes: 0 additions & 5 deletions packages/tizen_app_control/example/tizen/ui/.exportMap

This file was deleted.

12 changes: 4 additions & 8 deletions packages/tizen_app_control/example/tizen/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
flutter/
lib/*.so
res/flutter_assets/
res/icudtl.dat
.cproject
.sign
crash-info/
Debug/
Release/
.vs/
*.user
bin/
obj/
20 changes: 20 additions & 0 deletions packages/tizen_app_control/example/tizen/ui/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);
}
}
}
19 changes: 19 additions & 0 deletions packages/tizen_app_control/example/tizen/ui/Runner.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Tizen.NET.Sdk/1.1.7">

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

<ItemGroup>
<ProjectReference Include="$(FlutterEmbeddingPath)" />
</ItemGroup>

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

</Project>
6 changes: 0 additions & 6 deletions packages/tizen_app_control/example/tizen/ui/inc/runner.h

This file was deleted.

25 changes: 0 additions & 25 deletions packages/tizen_app_control/example/tizen/ui/project_def.prop

This file was deleted.

18 changes: 0 additions & 18 deletions packages/tizen_app_control/example/tizen/ui/src/runner.cc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.tizen.tizen_app_control_example" version="1.0.0" api-version="5.5" xmlns="http://tizen.org/ns/packages">
<profile name="wearable"/>
<ui-application appid="org.tizen.tizen_app_control_example" exec="runner" type="capp" multiple="false" nodisplay="false" taskmanage="true" hw-acceleration="on">
<profile name="common"/>
<ui-application appid="org.tizen.tizen_app_control_example" exec="Runner.dll" type="dotnet" multiple="false" nodisplay="false" taskmanage="true">
<label>tizen_app_control_example</label>
<icon>ic_launcher.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
</ui-application>
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
Expand Down

0 comments on commit 0f236e0

Please sign in to comment.