Skip to content

Commit

Permalink
feat: 权限申请
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Jan 16, 2024
1 parent 5b479ad commit 69e00b3
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ public interface Android {
@NonNull
Boolean isRunning();

@NonNull
Long getDeviceSdkInt();

@NonNull
String getDeviceCPUABI();

Expand Down Expand Up @@ -389,6 +392,28 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable Android ap
Boolean output = api.isRunning();
wrapped.add(0, output);
}
catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.alist_flutter.Android.getDeviceSdkInt", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
try {
Long output = api.getDeviceSdkInt();
wrapped.add(0, output);
}
catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class AndroidBridge(private val context: Context) : GeneratedApi.Android {

override fun isRunning() = AListService.isRunning

override fun getDeviceSdkInt(): Long {
return Build.VERSION.SDK_INT.toLong()
}

override fun getAListVersion() = BuildConfig.ALIST_VERSION


Expand Down
27 changes: 21 additions & 6 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,36 @@ class MessageLookup extends MessageLookupByLibrary {
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
"checkForUpdates":
MessageLookupByLibrary.simpleMessage("Check for updates"),
"copiedToClipboard": MessageLookupByLibrary.simpleMessage("已复制到剪贴板"),
"copiedToClipboard":
MessageLookupByLibrary.simpleMessage("Copied to clipboard"),
"currentIsLatestVersion":
MessageLookupByLibrary.simpleMessage("Current is latest version"),
"desktopShortcut":
MessageLookupByLibrary.simpleMessage("Desktop shortcut"),
"download": MessageLookupByLibrary.simpleMessage("下载"),
"download": MessageLookupByLibrary.simpleMessage("download"),
"downloadApk": MessageLookupByLibrary.simpleMessage("Download APK"),
"downloadThisFile": MessageLookupByLibrary.simpleMessage("下载此文件吗?"),
"downloadThisFile":
MessageLookupByLibrary.simpleMessage("Download this file?"),
"general": MessageLookupByLibrary.simpleMessage("General"),
"goTo": MessageLookupByLibrary.simpleMessage("前往"),
"jump_to_other_app":
"goTo": MessageLookupByLibrary.simpleMessage("GO"),
"grantManagerStoragePermission": MessageLookupByLibrary.simpleMessage(
"Grant 【Manage external storage】 permission"),
"grantNotificationPermission": MessageLookupByLibrary.simpleMessage(
"Grant 【Notification】 permission"),
"grantNotificationPermissionDesc": MessageLookupByLibrary.simpleMessage(
"Used for foreground service keep alive"),
"grantStoragePermission": MessageLookupByLibrary.simpleMessage(
"Grant 【external storage】 permission"),
"grantStoragePermissionDesc": MessageLookupByLibrary.simpleMessage(
"Mounting local storage is a must, otherwise no permission to read and write files"),
"importantSettings":
MessageLookupByLibrary.simpleMessage("Important settings"),
"jumpToOtherApp":
MessageLookupByLibrary.simpleMessage("Jump to other app?"),
"moreOptions": MessageLookupByLibrary.simpleMessage("More options"),
"releasePage": MessageLookupByLibrary.simpleMessage("Release Page"),
"selectAppToOpen": MessageLookupByLibrary.simpleMessage("选择应用打开"),
"selectAppToOpen":
MessageLookupByLibrary.simpleMessage("Select app to open"),
"setAdminPassword":
MessageLookupByLibrary.simpleMessage("Set admin password"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
Expand Down
11 changes: 11 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ class MessageLookup extends MessageLookupByLibrary {
"downloadThisFile": MessageLookupByLibrary.simpleMessage("下载此文件吗?"),
"general": MessageLookupByLibrary.simpleMessage("通用"),
"goTo": MessageLookupByLibrary.simpleMessage("前往"),
"grantManagerStoragePermission":
MessageLookupByLibrary.simpleMessage("申请【所有文件访问权限】"),
"grantNotificationPermission":
MessageLookupByLibrary.simpleMessage("申请【通知权限】"),
"grantNotificationPermissionDesc":
MessageLookupByLibrary.simpleMessage("用于前台服务保活"),
"grantStoragePermission":
MessageLookupByLibrary.simpleMessage("申请【读写外置存储权限】"),
"grantStoragePermissionDesc":
MessageLookupByLibrary.simpleMessage("挂载本地存储时必须授予,否则无权限读写文件"),
"importantSettings": MessageLookupByLibrary.simpleMessage("重要设置"),
"moreOptions": MessageLookupByLibrary.simpleMessage("更多选项"),
"releasePage": MessageLookupByLibrary.simpleMessage("发布页面"),
"selectAppToOpen": MessageLookupByLibrary.simpleMessage("选择应用打开"),
Expand Down
84 changes: 72 additions & 12 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions lib/generated_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,33 @@ class Android {
}
}

Future<int> getDeviceSdkInt() async {
const String __pigeon_channelName = 'dev.flutter.pigeon.alist_flutter.Android.getDeviceSdkInt';
final BasicMessageChannel<Object?> __pigeon_channel = BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
);
final List<Object?>? __pigeon_replyList =
await __pigeon_channel.send(null) as List<Object?>?;
if (__pigeon_replyList == null) {
throw _createConnectionError(__pigeon_channelName);
} else if (__pigeon_replyList.length > 1) {
throw PlatformException(
code: __pigeon_replyList[0]! as String,
message: __pigeon_replyList[1] as String?,
details: __pigeon_replyList[2],
);
} else if (__pigeon_replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (__pigeon_replyList[0] as int?)!;
}
}

Future<String> getDeviceCPUABI() async {
const String __pigeon_channelName = 'dev.flutter.pigeon.alist_flutter.Android.getDeviceCPUABI';
final BasicMessageChannel<Object?> __pigeon_channel = BasicMessageChannel<Object?>(
Expand Down
18 changes: 12 additions & 6 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
"bootAutoStartServiceDesc": "Automatically start AList service after boot. (Please make sure to grant auto-start permission)",
"webPage": "Web Page",
"settings": "Settings",
"jump_to_other_app": "Jump to other app?",
"selectAppToOpen": "选择应用打开",
"goTo": "前往",
"downloadThisFile": "下载此文件吗?",
"download": "下载",
"copiedToClipboard": "已复制到剪贴板"
"jumpToOtherApp": "Jump to other app?",
"selectAppToOpen": "Select app to open",
"goTo": "GO",
"downloadThisFile": "Download this file?",
"download": "download",
"copiedToClipboard": "Copied to clipboard",
"importantSettings": "Important settings",
"grantManagerStoragePermission": "Grant 【Manage external storage】 permission",
"grantStoragePermissionDesc": "Mounting local storage is a must, otherwise no permission to read and write files",
"grantStoragePermission": "Grant 【external storage】 permission",
"grantNotificationPermission": "Grant 【Notification】 permission",
"grantNotificationPermissionDesc": "Used for foreground service keep alive"
}
8 changes: 7 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@
"goTo": "前往",
"downloadThisFile": "下载此文件吗?",
"download": "下载",
"copiedToClipboard": "已复制到剪贴板"
"copiedToClipboard": "已复制到剪贴板",
"importantSettings": "重要设置",
"grantManagerStoragePermission": "申请【所有文件访问权限】",
"grantStoragePermissionDesc": "挂载本地存储时必须授予,否则无权限读写文件",
"grantStoragePermission": "申请【读写外置存储权限】",
"grantNotificationPermission": "申请【通知权限】",
"grantNotificationPermissionDesc": "用于前台服务保活"
}
22 changes: 13 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:alist_flutter/pages/settings/settings.dart';
import 'package:alist_flutter/pages/web/web.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_svg/svg.dart';
Expand Down Expand Up @@ -74,6 +75,7 @@ class _MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 0;
final PageController _pageController = PageController();


@override
void initState() {
super.initState();
Expand Down Expand Up @@ -106,18 +108,20 @@ class _MyHomePageState extends State<MyHomePage> {
},
),
bottomNavigationBar: NavigationBar(
destinations: [ NavigationDestination(
icon: const Icon(Icons.preview),
label: S.current.webPage,
),
destinations: [
NavigationDestination(
icon: SvgPicture.asset("assets/alist.svg",
color: Theme.of(context).hintColor,
width: 32,
height: 32,),
icon: const Icon(Icons.preview),
label: S.current.webPage,
),
NavigationDestination(
icon: SvgPicture.asset(
"assets/alist.svg",
color: Theme.of(context).hintColor,
width: 32,
height: 32,
),
label: S.current.appName,
),

NavigationDestination(
icon: const Icon(Icons.settings),
label: S.current.settings,
Expand Down
Loading

0 comments on commit 69e00b3

Please sign in to comment.