Add hiddify deeplink
This commit is contained in:
@@ -44,15 +44,13 @@
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data
|
||||
android:host="import-remote-profile"
|
||||
android:scheme="sing-box" />
|
||||
<data
|
||||
android:host="install-config"
|
||||
android:scheme="clash" />
|
||||
<data
|
||||
android:host="install-config"
|
||||
android:scheme="clashmeta" />
|
||||
<data android:scheme="sing-box"/>
|
||||
<data android:host="import-remote-profile"/>
|
||||
<data android:scheme="clash"/>
|
||||
<data android:host="install-config"/>
|
||||
<data android:scheme="clashmeta"/>
|
||||
<data android:scheme="hiddify"/>
|
||||
<data android:host="install-sub"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service
|
||||
|
||||
@@ -105,7 +105,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
final captureResult =
|
||||
await Clipboard.getData(Clipboard.kTextPlain);
|
||||
final link =
|
||||
LinkParser.simple(captureResult?.text ?? '');
|
||||
LinkParser.parse(captureResult?.text ?? '');
|
||||
if (link != null && context.mounted) {
|
||||
if (addProfileMutation.state.isInProgress) return;
|
||||
mutationTriggered.value = true;
|
||||
@@ -115,10 +115,12 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
.addProfile(link.url),
|
||||
);
|
||||
} else {
|
||||
if (context.mounted) {
|
||||
CustomToast.error(
|
||||
t.profile.add.invalidUrlMsg.sentenceCase,
|
||||
).show(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
const Gap(buttonsGap),
|
||||
|
||||
@@ -5,7 +5,11 @@ typedef ProfileLink = ({String url, String name});
|
||||
|
||||
// TODO: test and improve
|
||||
abstract class LinkParser {
|
||||
static const protocols = ['clash', 'clashmeta', 'sing-box'];
|
||||
static const protocols = ['clash', 'clashmeta', 'sing-box', 'hiddify'];
|
||||
|
||||
static ProfileLink? parse(String link) {
|
||||
return simple(link) ?? deep(link);
|
||||
}
|
||||
|
||||
static ProfileLink? simple(String link) {
|
||||
if (!isUrl(link)) return null;
|
||||
@@ -35,6 +39,11 @@ abstract class LinkParser {
|
||||
if (uri.authority != 'import-remote-profile' ||
|
||||
!queryParams.containsKey('url')) return null;
|
||||
return (url: queryParams['url']!, name: queryParams['name'] ?? '');
|
||||
case 'hiddify':
|
||||
if ((uri.authority != 'install-config' &&
|
||||
uri.authority != 'install-sub') ||
|
||||
!queryParams.containsKey('url')) return null;
|
||||
return (url: queryParams['url']!, name: queryParams['name'] ?? '');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string>clash</string>
|
||||
<string>clashmeta</string>
|
||||
<string>sing-box</string>
|
||||
<string>hiddify</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
Reference in New Issue
Block a user