feat(tool): 添加存储权限请求功能并优化代码
- 在 GlobalMethod.kt 中添加了请求存储权限的功能 - 优化了代码格式,调整了部分缩进和换行 - 移除了 shortcuts.xml 文件 - 在 strings.xml 中添加了权限请求相关的字符串资源
This commit is contained in:
parent
c65c684997
commit
31084d4793
|
@ -89,9 +89,6 @@
|
|||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ImporterActivity"
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.ClipData
|
|||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Context.CLIPBOARD_SERVICE
|
||||
import android.content.DialogInterface
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
|
@ -286,11 +287,21 @@ object GlobalMethod {
|
|||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
if (XXPermissions.isGranted(activity, list)) {
|
||||
return
|
||||
}
|
||||
MaterialAlertDialogBuilder(activity).setTitle(R.string.permission_request_title)
|
||||
.setMessage(R.string.permission_request_message)
|
||||
.setPositiveButton(
|
||||
R.string.dialog_ok
|
||||
) { _, _ ->
|
||||
XXPermissions.with(activity).permission(
|
||||
list
|
||||
).request { _, allGranted ->
|
||||
requestCompleted.invoke(allGranted)
|
||||
}
|
||||
}.setNegativeButton(R.string.dialog_cancel, null).setCancelable(false).show()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -616,4 +616,6 @@
|
|||
<string name="clipboard_cue_tip">在安卓13及以上系统,应用将内容复制到剪贴板时,弹出提示。</string>
|
||||
<string name="share">分享</string>
|
||||
<string name="variable_name">变量名</string>
|
||||
<string name="permission_request_title">请求权限</string>
|
||||
<string name="permission_request_message">我们需要存储权限以访问您的模组。</string>
|
||||
</resources>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shortcut
|
||||
android:enabled="true"
|
||||
android:icon="@drawable/table"
|
||||
android:shortcutDisabledMessage="@string/code_table"
|
||||
android:shortcutId="id1"
|
||||
android:shortcutLongLabel="@string/code_table"
|
||||
android:shortcutShortLabel="@string/code_table">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.coldmint.rust.pro.CodeTableActivity"
|
||||
android:targetPackage="com.coldmint.rust.pro" />
|
||||
<categories android:name="android.shortcut.conversation" />
|
||||
</shortcut>
|
||||
</shortcuts>
|
Loading…
Reference in New Issue
Block a user