|
|
@ -9,7 +9,10 @@ import androidx.lifecycle.Observer |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
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.ui.book.changecover.ChangeCoverDialog |
|
|
|
|
|
|
|
import io.legado.app.utils.RealPathUtil |
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
import kotlinx.android.synthetic.main.activity_book_info_edit.* |
|
|
|
import kotlinx.android.synthetic.main.activity_book_info_edit.* |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
@ -55,7 +58,7 @@ class BookInfoEditActivity : |
|
|
|
selectImage() |
|
|
|
selectImage() |
|
|
|
} |
|
|
|
} |
|
|
|
tv_refresh_cover.onClick { |
|
|
|
tv_refresh_cover.onClick { |
|
|
|
tie_cover_url.setText(viewModel.book?.customCoverUrl) |
|
|
|
viewModel.book?.customCoverUrl = tie_cover_url.text?.toString() |
|
|
|
upCover() |
|
|
|
upCover() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -107,7 +110,18 @@ class BookInfoEditActivity : |
|
|
|
resultSelectCover -> { |
|
|
|
resultSelectCover -> { |
|
|
|
if (resultCode == Activity.RESULT_OK) { |
|
|
|
if (resultCode == Activity.RESULT_OK) { |
|
|
|
data?.data?.let { uri -> |
|
|
|
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() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|