Коммит c6d33f8f создал по автору ovc-serega's avatar ovc-serega
Просмотр файлов

v0.2.1

владельцы aac2f0bd 2fbcdd99
## 0.1.0
### Changelog
## 0.2.1
- Added the ability to register an OpenURI intent for its processing
Standard and custom intents have been implemented
## 0.2.0
- Added the ability to register custom intents in the Aurora OS
## 0.1.0
## 0.2.0
Added the ability to register custom intents in the Aurora OS
- Standard and custom intents have been implemented
......@@ -45,10 +45,6 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(runtime-manager-qt5)
```
Add your intents to the `desktop` file:
```desktop
Intents=X-MyIntent;X-MyIntent2
```
You also need to enable Qt support in `aurora/main.cpp`:
```cpp
......@@ -83,7 +79,7 @@ Future<Map<String, dynamic>> invokeIntent({required String name, Hints? hints, M
- `name` - name of the intent:
- standard `AuroraStandartIntents`:
- `Start` - to start any actions or processes;
- `Openurl` - to open a specific URI;
- `OpenURI` - to open a specific URI;
- custom;
- `hints` - hints for the intent service;
- `params` - an arbitrary collection of parameters.
......@@ -119,7 +115,7 @@ Future<void> registerIntent(String name, Future<JsonMap?> Function(Map<String, d
```
#### Arguments
- `name` - invent name, names start with "X-";
- `name` - invent name, name is either `OpenURI` or it starts with "X-";
- `callback` - the intent handler method.
#### Example
......@@ -131,6 +127,19 @@ await AuroraIntent.registerIntent("X-MyIntent", (params) async {
});
```
#### Registering your own intents in a `desktop` file:
```desktop
Intents=X-MyIntent
```
#### Registration of URI schemes in a `desktop` file:
```desktop
MimeType=x-scheme-handler/geo
```
IANA approved schemes are supported (https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml ) and a diagram starting with "aurora-<organization name>.".
Avoid using "_" in schema names.
### startService
It registers the added intents in the Runtime Manager, after which the interns become available for calling by the OS.
......
......@@ -45,11 +45,6 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(runtime-manager-qt5)
```
Добавить ваши интенты в `desktop` файл:
```desktop
Intents=X-MyIntent;X-MyIntent2
```
Также нужно подключить поддержку Qt в `aurora/main.cpp`:
```cpp
...
......@@ -119,7 +114,7 @@ Future<void> registerIntent(String name, Future<JsonMap?> Function(Map<String, d
```
#### Аргументы
- `name` - название интента, названия начинаются с "X-";
- `name` - название интента, название или `OpenURI`, или начинаются с "X-";
- `callback` - метод обработчик интента.
#### Пример
......@@ -131,6 +126,18 @@ await AuroraIntent.registerIntent("X-MyIntent", (params) async {
});
```
#### Регистрация собственных интентов в `desktop` файле:
```desktop
Intents=X-MyIntent
```
#### Регистрация URI cхем в `desktop` файле:
```desktop
MimeType=x-scheme-handler/geo
```
Поддерживаются схемы одобренные IANA (https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml) и схемы, начинающаяся с "aurora-<название_организации>.".
Избегайте использование "_" в названиях схем.
### startService
Регистрирует добавленные интенты в Runtime Manager, после этого интенты становятся доступны для вызова ОС.
......
......@@ -91,7 +91,6 @@ void IntentManager::registerIntent(const std::string& intentName) {
RuntimeManager::RuntimeDispatcher::CustomHandler customHandler =
[this, intentName](const QJsonObject& params, const RuntimeManager::RuntimeDispatcher::HandlerCb& reply) {
spdlog::info("OS called intent: {}, Params :{} ", intentName, params);
std::cout << "Called intent:" << intentName << std::endl;
const auto callbackId = getCallbackId();
......
......@@ -8,6 +8,7 @@ The example demonstrates:
- opening a uri
- create customs intenets
- invoke custom intents
- registration of URI schemes and their processing
## Screenshots
......
# aurora_intent_example
В этом примере показано, как вызывать intents и создавать свои собственные intents в операционной системе Aurora OS
## Описание
В примере показано:
- запуск приложения
- открытие uri
- создание пользовательских интентов
- вызов пользовательских интентов
- регистрация URI схем и их обработка
## Скриншоты
![Главный экран](screenshots/main_page.png)
![Запуск приложения](screenshots/start_app.png)
![Вызов URI телефона](screenshots/open_uri.png)
![Запуск пользовательского интента](screenshots/call_intent.png)
......@@ -5,9 +5,10 @@ Comment=Example for intents for AuroraOS
Icon=ru.aurora.aurora_intent_example
Exec=/usr/bin/ru.aurora.aurora_intent_example
X-Nemo-Application-Type=silica-qt5
MimeType=x-scheme-handler/geo
[X-Application]
Permissions=
OrganizationName=ru.aurora
ApplicationName=aurora_intent_example
Intents=X-MyIntent;X-MyIntent2
Intents=X-MyIntent
......@@ -13,15 +13,15 @@ void main() async {
return {"counter": ++counter};
});
await AuroraIntent.registerIntent("X-MyIntent2", _intentHandler);
await AuroraIntent.registerIntent(AuroraStandartIntents.openUri, _uriHandler);
await AuroraIntent.startService();
runApp(const MyApp());
}
Map<String, dynamic>? _intentHandler(Map<String, dynamic> params) {
debugPrint("Invoke X-MyIntent2");
Map<String, dynamic>? _uriHandler(Map<String, dynamic> params) {
debugPrint("Invoke URI: $params");
return null;
}
......@@ -100,8 +100,13 @@ class _HomePageState extends State<HomePage> {
child: const Text("Invoke X-MyIntent"),
),
ElevatedButton(
onPressed: () async => await AuroraIntent.invokeIntent(name: "X-MyIntent2"),
child: const Text("Invoke X-MyIntent2"),
onPressed: () async {
await AuroraIntent.invokeIntent(
name: AuroraStandartIntents.openUri,
params: {'uri': 'geo:0.0,0.0'},
);
},
child: const Text("Invoke geo URI"),
),
],
)
......
name: aurora_intent_example
description: "Example for intents for aurora"
version: 0.2.0
version: 0.2.1
publish_to: "none"
environment:
......
......@@ -81,10 +81,10 @@ class AuroraIntentPlatform extends AuroraIntentPlatformInterface {
@override
Future<void> registerIntent(String name, IntentHandler callback) async {
if (!name.startsWith("X-")) {
if (!(name.startsWith("X-") || name == AuroraStandartIntents.openUri)) {
throw IntentException(
code: IntentErrorCode.incorrectCustomIntentName,
message: "Custom intent name must start with 'X-'",
message: "Custom intent name must start with 'X-' or OpenURI",
);
}
......
name: aurora_intent
description: "Intent to Aurora OS"
version: 0.2.0
version: 0.2.1
publish_to: none
environment:
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать