mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-09 19:10:51 +00:00
优化:在选择Web客户端目录的时候弹出授权管理所有文件访问的权限 #332
This commit is contained in:
parent
103b1f5839
commit
0bb562b43d
@ -1,5 +1,6 @@
|
||||
package com.idormy.sms.forwarder.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Environment
|
||||
import android.os.Handler
|
||||
@ -308,6 +309,11 @@ class ServerFragment : BaseFragment<FragmentServerBinding?>(), View.OnClickListe
|
||||
XToastUtils.info(String.format(getString(R.string.copied_to_clipboard), url))
|
||||
}
|
||||
R.id.btn_path_picker -> {
|
||||
// 申请储存权限
|
||||
XXPermissions.with(this)
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE).request(object : OnPermissionCallback {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onGranted(permissions: List<String>, all: Boolean) {
|
||||
val downloadPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path
|
||||
val dirList = listSubDir(downloadPath)
|
||||
if (dirList.isEmpty()) {
|
||||
@ -333,6 +339,19 @@ class ServerFragment : BaseFragment<FragmentServerBinding?>(), View.OnClickListe
|
||||
true // allow selection
|
||||
}.positiveText(R.string.select).negativeText(R.string.cancel).show()
|
||||
}
|
||||
|
||||
override fun onDenied(permissions: List<String>, never: Boolean) {
|
||||
if (never) {
|
||||
XToastUtils.error(R.string.toast_denied_never)
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(requireContext(), permissions)
|
||||
} else {
|
||||
XToastUtils.error(R.string.toast_denied)
|
||||
}
|
||||
binding!!.etWebPath.setText(getString(R.string.storage_permission_tips))
|
||||
}
|
||||
})
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user