From 667cd533695ae7c05d3f33d85c06ae8f0d0ad236 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 10 May 2020 18:29:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/info/edit/BookInfoEditActivity.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index e0b76ce1f..f7ff39be4 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -9,7 +9,10 @@ import androidx.lifecycle.Observer import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book +import io.legado.app.help.permission.Permissions +import io.legado.app.help.permission.PermissionsCompat import io.legado.app.ui.book.changecover.ChangeCoverDialog +import io.legado.app.utils.RealPathUtil import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_book_info_edit.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -55,7 +58,7 @@ class BookInfoEditActivity : selectImage() } tv_refresh_cover.onClick { - tie_cover_url.setText(viewModel.book?.customCoverUrl) + viewModel.book?.customCoverUrl = tie_cover_url.text?.toString() upCover() } } @@ -107,7 +110,18 @@ class BookInfoEditActivity : resultSelectCover -> { if (resultCode == Activity.RESULT_OK) { data?.data?.let { uri -> - coverChangeTo(uri.toString()) + RealPathUtil.getPath(this, uri)?.let { path -> + PermissionsCompat.Builder(this) + .addPermissions( + Permissions.READ_EXTERNAL_STORAGE, + Permissions.WRITE_EXTERNAL_STORAGE + ) + .rationale(R.string.get_storage_per) + .onGranted { + coverChangeTo(path) + } + .request() + } } } }