added deep link for custom buttons

This commit is contained in:
Schnitzel5 2025-08-05 01:48:19 +02:00
parent a101d10826
commit 2eca6576a2
20 changed files with 121 additions and 9 deletions

View file

@ -36,6 +36,12 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mangayomi" android:host="add-repo" />
</intent-filter>
<intent-filter android:label="Add custom button">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mangayomi" android:host="add-button" />
</intent-filter>
</activity>
<activity
android:name="com.linusu.flutter_web_auth_2.CallbackActivity"

Binary file not shown.

View file

@ -484,6 +484,7 @@
"custom_buttons_info": "Execute lua code with custom buttons",
"custom_buttons_edit": "Edit custom buttons",
"custom_buttons_add": "Add custom button",
"custom_buttons_added": "Custom button added!",
"custom_buttons_delete": "Delete custom button",
"custom_buttons_text": "Button text",
"custom_buttons_text_req": "Button text required",

View file

@ -2979,6 +2979,12 @@ abstract class AppLocalizations {
/// **'Add custom button'**
String get custom_buttons_add;
/// No description provided for @custom_buttons_added.
///
/// In en, this message translates to:
/// **'Custom button added!'**
String get custom_buttons_added;
/// No description provided for @custom_buttons_delete.
///
/// In en, this message translates to:

View file

@ -1532,6 +1532,9 @@ class AppLocalizationsAr extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1534,6 +1534,9 @@ class AppLocalizationsAs extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1545,6 +1545,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1533,6 +1533,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1550,6 +1550,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1551,6 +1551,9 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1535,6 +1535,9 @@ class AppLocalizationsHi extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1539,6 +1539,9 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1548,6 +1548,9 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1547,6 +1547,9 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1549,6 +1549,9 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1533,6 +1533,9 @@ class AppLocalizationsTh extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1539,6 +1539,9 @@ class AppLocalizationsTr extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -1504,6 +1504,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get custom_buttons_add => 'Add custom button';
@override
String get custom_buttons_added => 'Custom button added!';
@override
String get custom_buttons_delete => 'Delete custom button';

View file

@ -14,6 +14,7 @@ import 'package:hive_flutter/adapters.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:isar/isar.dart';
import 'package:mangayomi/eval/model/m_bridge.dart';
import 'package:mangayomi/models/custom_button.dart';
import 'package:mangayomi/models/manga.dart';
import 'package:mangayomi/models/settings.dart';
import 'package:mangayomi/models/source.dart';
@ -145,7 +146,7 @@ class _MyAppState extends ConsumerState<MyApp> {
Future<void> _initDeepLinks() async {
_appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
_linkSubscription = _appLinks.uriLinkStream.listen((uri) async {
if (uri == lastUri) return; // Debouncing Deep Links
lastUri = uri;
switch (uri.host) {
@ -224,6 +225,62 @@ class _MyAppState extends ConsumerState<MyApp> {
},
);
break;
case "add-button":
final buttonDataRaw = uri.queryParametersAll["button"];
final context = navigatorKey.currentContext;
if (context == null || !context.mounted || buttonDataRaw == null) {
return;
}
final l10n = context.l10n;
for (final buttonRaw in buttonDataRaw) {
final buttonData = jsonDecode(
utf8.decode(base64.decode(buttonRaw)),
);
if (buttonData is Map<String, dynamic>) {
final customButton = CustomButton.fromJson(buttonData);
await showDialog(
context: navigatorKey.currentContext!,
builder: (BuildContext context) {
return AlertDialog(
title: Text(l10n.custom_buttons_add),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${l10n.name}: ${customButton.title ?? 'Unknown'}",
),
],
),
actions: [
TextButton(
child: Text(l10n.cancel),
onPressed: () => Navigator.of(context).pop(),
),
FilledButton(
child: Text(l10n.add),
onPressed: () async {
if (context.mounted) Navigator.of(context).pop();
await isar.writeTxn(() async {
await isar.customButtons.put(
customButton
..pos = await isar.customButtons.count()
..isFavourite = false
..id = null
..updatedAt =
DateTime.now().millisecondsSinceEpoch,
);
});
botToast(l10n.custom_buttons_added);
},
),
],
);
},
);
}
}
break;
default:
}
});

View file

@ -1164,7 +1164,7 @@ packages:
description:
path: media_kit
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.2.0"
@ -1173,7 +1173,7 @@ packages:
description:
path: "libs/android/media_kit_libs_android_video"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.3.7"
@ -1182,7 +1182,7 @@ packages:
description:
path: "libs/ios/media_kit_libs_ios_video"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.1.4"
@ -1191,7 +1191,7 @@ packages:
description:
path: "libs/linux/media_kit_libs_linux"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.2.1"
@ -1200,7 +1200,7 @@ packages:
description:
path: "libs/macos/media_kit_libs_macos_video"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.1.4"
@ -1209,7 +1209,7 @@ packages:
description:
path: "libs/universal/media_kit_libs_video"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.0.6"
@ -1218,7 +1218,7 @@ packages:
description:
path: "libs/windows/media_kit_libs_windows_video"
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.0.11"
@ -1227,7 +1227,7 @@ packages:
description:
path: media_kit_video
ref: HEAD
resolved-ref: "3008dfd943502bcb83e50a56a7e86bb887170cd6"
resolved-ref: "08e91da7229c818a25822b3cd3d77415d5f2af36"
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.3.0"