♻️ Refactor andoird default folder
This commit is contained in:
parent
1661a884ca
commit
b5c4837076
|
@ -49,10 +49,8 @@
|
|||
</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" />
|
||||
|
@ -63,8 +61,6 @@
|
|||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="pika" />
|
||||
</intent-filter>
|
||||
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"></action>
|
||||
<category android:name="android.intent.category.DEFAULT"></category>
|
||||
|
@ -78,6 +74,12 @@
|
|||
<data android:pathPattern=".*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pki"></data>
|
||||
<data
|
||||
android:host="*"
|
||||
android:mimeType="*/*"
|
||||
|
@ -88,6 +90,12 @@
|
|||
<data android:pathPattern=".*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pkz"></data>
|
||||
<data android:pathPattern=".*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\.pki"></data>
|
||||
<data android:pathPattern=".*\..*\..*\..*\..*\..*\.pki"></data>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
|
|
|
@ -102,6 +102,7 @@ class MainActivity : FlutterActivity() {
|
|||
"androidGetExtendDirs" -> androidGetExtendDirs()
|
||||
"androidSecureFlag" -> androidSecureFlag(call.argument("flag")!!)
|
||||
"verifyAuthentication" -> auth()
|
||||
"androidStorageRoot" -> storageRoot()
|
||||
else -> {
|
||||
notImplementedToken
|
||||
}
|
||||
|
@ -404,5 +405,7 @@ class MainActivity : FlutterActivity() {
|
|||
return queue.poll(5, TimeUnit.MINUTES) ?: false
|
||||
}
|
||||
|
||||
|
||||
fun storageRoot(): String {
|
||||
return Environment.getExternalStorageDirectory().absolutePath
|
||||
}
|
||||
}
|
||||
|
|
|
@ -972,4 +972,8 @@ class Method {
|
|||
String ms = await _flatInvoke("ping", idx);
|
||||
return int.parse(ms);
|
||||
}
|
||||
|
||||
Future<String> androidStorageRoot() async {
|
||||
return await _channel.invokeMethod("androidStorageRoot");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,16 @@ import 'package:permission_handler/permission_handler.dart';
|
|||
|
||||
import '../Common.dart';
|
||||
import '../Method.dart';
|
||||
import 'Platform.dart';
|
||||
|
||||
const _propertyName = "chooserRoot";
|
||||
late String _chooserRoot;
|
||||
late String _androidDefaultRoot;
|
||||
|
||||
Future<dynamic> initChooserRoot() async {
|
||||
_chooserRoot = await method.loadProperty(_propertyName, "");
|
||||
if (Platform.isAndroid) {
|
||||
_androidDefaultRoot = await method.androidStorageRoot();
|
||||
}
|
||||
}
|
||||
|
||||
String _currentChooserRoot() {
|
||||
|
@ -25,7 +28,7 @@ String _currentChooserRoot() {
|
|||
} else if (Platform.isLinux) {
|
||||
return '/';
|
||||
} else if (Platform.isAndroid) {
|
||||
return '/storage/emulated/0';
|
||||
return _androidDefaultRoot;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
@ -35,16 +38,10 @@ String _currentChooserRoot() {
|
|||
|
||||
Future<String> currentChooserRoot() async {
|
||||
if (Platform.isAndroid) {
|
||||
if (androidVersion >= 30) {
|
||||
if (!(await Permission.manageExternalStorage.request()).isGranted) {
|
||||
throw Exception("申请权限被拒绝");
|
||||
}
|
||||
} else {
|
||||
if (!(await Permission.storage.request()).isGranted) {
|
||||
throw Exception("申请权限被拒绝");
|
||||
}
|
||||
}
|
||||
}
|
||||
return _currentChooserRoot();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue