♻️ Refactor andoird intent filter

This commit is contained in:
niuhuan 2023-03-22 16:16:13 +08:00
parent 93839672f5
commit 1661a884ca
8 changed files with 119 additions and 123 deletions

View File

@ -6,8 +6,7 @@
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<queries>
<intent>
@ -20,11 +19,10 @@
android:icon="@mipmap/ic_launcher"
android:label="pikapika"
android:requestLegacyExternalStorage="true">
<!-- requestLegacyExternalStorage="true" api29 down -->
<activity
android:name=".MainActivity"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
@ -44,51 +42,52 @@
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="pika" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="pika" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:pathPattern=".*\\.pkz" android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:pathPattern=".*\\.pki" android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:pathPattern=".*\\.zip" android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:pathPattern=".*\\.pkz" android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:pathPattern=".*\\.pki" android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:pathPattern=".*\\.zip" android:host="*" />
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data
android:host="*"
android:mimeType="*/*"
android:scheme="content"></data>
<data android:pathPattern=".*\.pkz"></data>
<data android:pathPattern=".*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pkz"></data>
<data
android:host="*"
android:mimeType="*/*"
android:scheme="file"></data>
<data android:pathPattern=".*\.pkz"></data>
<data android:pathPattern=".*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\..*\.pkz"></data>
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pkz"></data>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
@ -98,8 +97,8 @@
android:value="2" />
<!-- image_cropper -->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
</application>
</manifest>

View File

@ -1 +1 @@
v1.6.7
v1.6.8

View File

@ -1,11 +1,5 @@
v1.6.7
- [x] ✨找回密码
- [x] ✨webDav
- [x] ✨自动同步历史记录(发电)
- [x] ♻️注册登录更友善的提示(有些人看不懂英文)
- [x] ✨快速切换封印模式菜单
- [x] ✨阉割掉注册
- [x] ✨快速切换分流
- [x] ✨导出图片zip
v1.6.8
- [x] ✨测速(界面还未实现)
- [x] ♻️优化安卓文件关联
- [x] ♻优化安卓URL匹配

View File

@ -299,6 +299,7 @@ Future<String?> inputString(BuildContext context, String title,
StreamSubscription<String?> linkSubscript(BuildContext context) {
return linkStream.listen((uri) async {
if (uri == null) return;
var parsed = Uri.parse(uri);
if (RegExp(r"^pika://comic/([0-9A-z]+)/$").allMatches(uri).isNotEmpty) {
String comicId = RegExp(r"^pika://comic/([0-9A-z]+)/$")
.allMatches(uri)
@ -309,7 +310,17 @@ StreamSubscription<String?> linkSubscript(BuildContext context) {
builder: (BuildContext context) => ComicInfoScreen(comicId: comicId),
),
);
} else if (RegExp(r"^.*\.pkz$").allMatches(uri).isNotEmpty) {
} else if (RegExp(r"^https?://pika/comic/([0-9A-z]+)/$").allMatches(uri).isNotEmpty) {
String comicId = RegExp(r"^https?://pika/comic/([0-9A-z]+)/$")
.allMatches(uri)
.first
.group(1)!;
Navigator.of(context).push(
mixRoute(
builder: (BuildContext context) => ComicInfoScreen(comicId: comicId),
),
);
} else if (RegExp(r"^.*\.pkz$").allMatches(parsed.path).isNotEmpty) {
File file = await toFile(uri);
Navigator.of(context).push(
mixRoute(
@ -317,7 +328,7 @@ StreamSubscription<String?> linkSubscript(BuildContext context) {
PkzArchiveScreen(pkzPath: file.path),
),
);
} else if (RegExp(r"^.*\.((pki)|(zip))$").allMatches(uri).isNotEmpty) {
} else if (RegExp(r"^.*\.((pki)|(zip))$").allMatches(parsed.path).isNotEmpty) {
File file = await toFile(uri);
Navigator.of(context).push(
mixRoute(

View File

@ -582,10 +582,10 @@ class Method {
/// HTML+JPG
Future<dynamic> exportComicDownloadToJPG(
String comicId,
String dir,
String name,
) {
String comicId,
String dir,
String name,
) {
return _flatInvoke("exportComicDownloadToJPG", {
"comicId": comicId,
"dir": dir,
@ -595,10 +595,10 @@ class Method {
/// HTML+JPG
Future<dynamic> exportComicDownloadJpegZip(
String comicId,
String dir,
String name,
) {
String comicId,
String dir,
String name,
) {
return _flatInvoke("exportComicDownloadJpegZip", {
"comicId": comicId,
"dir": dir,
@ -967,4 +967,9 @@ class Method {
"file": file,
});
}
Future<int> ping(String idx) async {
String ms = await _flatInvoke("ping", idx);
return int.parse(ms);
}
}

View File

@ -81,38 +81,17 @@ class _AccountScreenState extends State<AccountScreen> {
appBar: AppBar(
title: const Text('配置'),
actions: [
IconButton(
onPressed: () {
setState(() {
_versionClick++;
});
},
icon: Text(currentVersion()),
SizedBox(
width: 80,
child: IconButton(
onPressed: () {
setState(() {
_versionClick++;
});
},
icon: Text(currentVersion()),
),
),
// IconButton(
// onPressed: () {
// Navigator.push(
// context,
// mixRoute(
// builder: (context) => const SettingsScreen(
// hiddenAccountInfo: true,
// ),
// ),
// );
// },
// icon: const Text('设置'),
// ),
// IconButton(
// onPressed: () {
// Navigator.push(
// context,
// mixRoute(
// builder: (context) => const AboutScreen(),
// ),
// );
// },
// icon: const Text('关于'),
// ),
IconButton(
onPressed: _toDownloadList,
icon: const Icon(Icons.download_rounded),

View File

@ -124,6 +124,7 @@ class _InitScreenState extends State<InitScreen> {
}
}
if (initUrl != null) {
var parsed = Uri.parse(initUrl!);
if (RegExp(r"^pika://comic/([0-9A-z]+)/$").allMatches(initUrl!).isNotEmpty) {
String comicId = RegExp(r"^pika://comic/([0-9A-z]+)/$").allMatches(initUrl!).first.group(1)!;
Navigator.of(context).pushReplacement(mixRoute(
@ -131,14 +132,21 @@ class _InitScreenState extends State<InitScreen> {
ComicInfoScreen(comicId: comicId, holdPkz: true),
));
return;
} else if (RegExp(r"^.*\.pkz$").allMatches(initUrl!).isNotEmpty) {
} if (RegExp(r"^https?://pika/comic/([0-9A-z]+)/$").allMatches(initUrl!).isNotEmpty) {
String comicId = RegExp(r"^https?://pika/comic/([0-9A-z]+)/$").allMatches(initUrl!).first.group(1)!;
Navigator.of(context).pushReplacement(mixRoute(
builder: (BuildContext context) =>
ComicInfoScreen(comicId: comicId, holdPkz: true),
));
return;
} else if (RegExp(r"^.*\.pkz$").allMatches(parsed.path).isNotEmpty) {
File file = await toFile(initUrl!);
Navigator.of(context).pushReplacement(mixRoute(
builder: (BuildContext context) =>
PkzArchiveScreen(pkzPath: file.path, holdPkz: true),
));
return;
} else if (RegExp(r"^.*\.((pki)|(zip))$").allMatches(initUrl!).isNotEmpty) {
} else if (RegExp(r"^.*\.((pki)|(zip))$").allMatches(parsed.path).isNotEmpty) {
File file = await toFile(initUrl!);
Navigator.of(context).pushReplacement(
mixRoute(

View File

@ -77,10 +77,10 @@ packages:
dependency: "direct main"
description:
name: crop_image
sha256: "78715179b0d3cd1e9e0a5c4a7846851acf33db346c657674b9abc358e84a511d"
sha256: b2db908b9d5cba7861d4b1337b9ea7b76309b55d38fd1c9ffea3308764b5990d
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.0.4"
cross_file:
dependency: transitive
description:
@ -133,10 +133,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9
sha256: d8e9ca7e5d1983365c277f12c21b4362df6cf659c99af146ad4d04eb33033013
url: "https://pub.dev"
source: hosted
version: "5.2.5"
version: "5.2.6"
filesystem_picker:
dependency: "direct main"
description:
@ -175,10 +175,10 @@ packages:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: "4bef634684b2c7f3468c77c766c831229af829a0cd2d4ee6c1b99558bd14e5d2"
sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf
url: "https://pub.dev"
source: hosted
version: "2.0.8"
version: "2.0.9"
flutter_search_bar:
dependency: "direct main"
description:
@ -249,34 +249,34 @@ packages:
dependency: "direct main"
description:
name: image_picker
sha256: "22207768556b82d55ec70166824350fee32298732d5efa4d6e756f848f51f66a"
sha256: "64b21d9f0e065f9ab0e4dde458076226c97382cc0c6949144cb874c62bf8e9f8"
url: "https://pub.dev"
source: hosted
version: "0.8.6+3"
version: "0.8.7"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
sha256: "68d067baf7f6e401b1124ee83dd6967e67847314250fd68012aab34a69beb344"
sha256: b81db5f5ed8a69d54d5f0932c2af8120e8c0518a037d8beee494eec671da4d4c
url: "https://pub.dev"
source: hosted
version: "0.8.5+7"
version: "0.8.6+5"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
sha256: "66fc6e3877bbde82c33d122f3588777c3784ac5bd7d1cdd79213ef7aecb85b34"
sha256: "98f50d6b9f294c8ba35e25cc0d13b04bfddd25dbc8d32fa9d566a6572f2c081c"
url: "https://pub.dev"
source: hosted
version: "2.1.11"
version: "2.1.12"
image_picker_ios:
dependency: transitive
description:
name: image_picker_ios
sha256: "39aa70b5f1e5e7c94585b9738632d5fdb764a5655e40cd9e7b95fbd2fc50c519"
sha256: "50e882fe0a06bf0c8f7f5bce78d30975f279213293afc9471dc35f05617c50ff"
url: "https://pub.dev"
source: hosted
version: "0.8.6+9"
version: "0.8.7+1"
image_picker_platform_interface:
dependency: transitive
description:
@ -449,10 +449,10 @@ packages:
dependency: transitive
description:
name: pointycastle
sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
sha256: "57b6b78df14175658f09c5dfcfc51a46ad9561a3504fe679913dab404d0cc0f2"
url: "https://pub.dev"
source: hosted
version: "3.6.2"
version: "3.7.0"
scrollable_positioned_list:
dependency: "direct main"
description:
@ -566,34 +566,34 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "1f4d9ebe86f333c15d318f81dcdc08b01d45da44af74552608455ebdc08d9732"
sha256: "845530e5e05db5500c1a4c1446785d60cbd8f9bd45e21e7dd643a3273bb4bbd1"
url: "https://pub.dev"
source: hosted
version: "6.0.24"
version: "6.0.25"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: c9cd648d2f7ab56968e049d4e9116f96a85517f1dd806b96a86ea1018a3a82e5
sha256: "3dedc66ca3c0bef9e6a93c0999aee102556a450afcc1b7bcfeace7a424927d92"
url: "https://pub.dev"
source: hosted
version: "6.1.1"
version: "6.1.3"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: e29039160ab3730e42f3d811dc2a6d5f2864b90a70fb765ea60144b03307f682
sha256: "206fb8334a700ef7754d6a9ed119e7349bc830448098f21a69bf1b4ed038cabc"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.4"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "2dddb3291a57b074dade66b5e07e64401dd2487caefd4e9e2f467138d8c7eb06"
sha256: "0ef2b4f97942a16523e51256b799e9aa1843da6c60c55eefbfa9dbc2dcb8331a"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.4"
url_launcher_platform_interface:
dependency: transitive
description:
@ -606,18 +606,18 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "574cfbe2390666003c3a1d129bdc4574aaa6728f0c00a4829a81c316de69dd9b"
sha256: "81fe91b6c4f84f222d186a9d23c73157dc4c8e1c71489c4d08be1ad3b228f1aa"
url: "https://pub.dev"
source: hosted
version: "2.0.15"
version: "2.0.16"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "97c9067950a0d09cbd93e2e3f0383d1403989362b97102fbf446473a48079a4b"
sha256: a83ba3607a507758669cfafb03f9de09bf6e6280c14d9b9cb18f013e406dcacd
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.0.5"
vector_math:
dependency: transitive
description: