Merge pull request #52 from Celeter/master

SDK版本大于28提示需要安装外部来源应用的权限
pull/53/head
kunfei 5 years ago committed by GitHub
commit 4b0c69500b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt

@ -1,6 +1,9 @@
package io.legado.app.ui.config package io.legado.app.ui.config
import android.content.Intent
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.provider.Settings
import android.text.InputType import android.text.InputType
import android.view.View import android.view.View
import androidx.preference.EditTextPreference import androidx.preference.EditTextPreference
@ -99,6 +102,27 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference
} }
private fun importOld() { private fun importOld() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
val haveInstallPermission = context!!.packageManager.canRequestPackageInstalls()
if (haveInstallPermission) {
startImport()
} else { //没有安装外部来源应用的权限
alert(title = "开启权限提示") {
message = "需要打开「安装外部来源应用」权限才能导入旧版数据,请去设置中开启"
yesButton {
val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES)
startActivityForResult(intent, 666)
}
noButton {
}
}.show().applyTint()
}
} else {
startImport()
}
}
private fun startImport() {
alert(title = "导入") { alert(title = "导入") {
message = "是否导入旧版本数据" message = "是否导入旧版本数据"
yesButton { yesButton {

Loading…
Cancel
Save