From 34df3e3af964a9f45e4a981444694b126694f5ac Mon Sep 17 00:00:00 2001 From: Celeter Date: Wed, 4 Dec 2019 21:33:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?SDK=E7=89=88=E6=9C=AC=E5=A4=A7=E4=BA=8E28?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=9C=80=E8=A6=81=E5=AE=89=E8=A3=85=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E6=9D=A5=E6=BA=90=E5=BA=94=E7=94=A8=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/config/WebDavConfigFragment.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt index 0d685c407..cd9b6e7c5 100644 --- a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt @@ -1,6 +1,9 @@ package io.legado.app.ui.config +import android.content.Intent +import android.os.Build import android.os.Bundle +import android.provider.Settings import android.text.InputType import android.view.View import androidx.preference.EditTextPreference @@ -99,6 +102,27 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference } 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 = "导入") { message = "是否导入旧版本数据" yesButton { From de85b382b8e4203d0862c69fbaf684ce58cbc835 Mon Sep 17 00:00:00 2001 From: Celeter Date: Wed, 4 Dec 2019 21:37:44 +0800 Subject: [PATCH 2/2] up --- .../main/java/io/legado/app/ui/config/WebDavConfigFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt index cd9b6e7c5..a29c34057 100644 --- a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt @@ -108,7 +108,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), Preference.OnPreference startImport() } else { //没有安装外部来源应用的权限 alert(title = "开启权限提示") { - message = "还需要打开「安装外部来源应用」权限才能导入旧版数据,请去设置中开启" + message = "需要打开「安装外部来源应用」权限才能导入旧版数据,请去设置中开启" yesButton { val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES) startActivityForResult(intent, 666)