diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 10bea623a..c7d5926d7 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -8,6 +8,7 @@ * 修复翻页模式选择颜色问题 * 修复toolbar在一些情况下文字颜色不对的bug * 多设备阅读记录叠加 +* 封面链接支持修改headers **2020/08/24** * 应用被杀死时停止朗读 diff --git a/app/src/main/java/io/legado/app/help/ImageLoader.kt b/app/src/main/java/io/legado/app/help/ImageLoader.kt index 11f8dff21..9a58f45bf 100644 --- a/app/src/main/java/io/legado/app/help/ImageLoader.kt +++ b/app/src/main/java/io/legado/app/help/ImageLoader.kt @@ -9,6 +9,7 @@ import com.bumptech.glide.Glide import com.bumptech.glide.RequestBuilder import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isContentPath +import io.legado.app.model.analyzeRule.AnalyzeUrl import java.io.File object ImageLoader { @@ -19,7 +20,7 @@ object ImageLoader { fun load(context: Context, path: String?): RequestBuilder { return when { path.isNullOrEmpty() -> Glide.with(context).load(path) - path.isAbsUrl() -> Glide.with(context).load(path) + path.isAbsUrl() -> Glide.with(context).load(AnalyzeUrl(path).getGlideUrl()) path.isContentPath() -> Glide.with(context).load(Uri.parse(path)) else -> try { Glide.with(context).load(File(path)) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 2ed80701b..56b1f1c0e 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -22,7 +22,8 @@ import java.net.URLEncoder import java.util.* import java.util.regex.Pattern import javax.script.SimpleBindings - +import com.bumptech.glide.load.model.GlideUrl +import com.bumptech.glide.load.model.LazyHeaders /** * Created by GKF on 2018/1/24. @@ -346,9 +347,7 @@ class AnalyzeUrl( } @Throws(Exception::class) - fun getImageBytes( - tag: String - ): ByteArray? { + fun getImageBytes(tag: String): ByteArray? { //资源为本站的资源,保留cookie //图片盗链的不保留当前的cookie,可由js生成图片源站的cookie val cookie = CookieStore.getCookie(tag) @@ -403,6 +402,19 @@ class AnalyzeUrl( return response.body() } + @Throws(Exception::class) + fun getGlideUrl(): Any? { + var glideUrl: Any = url + if(headerMap.isNotEmpty()) { + val Headers = LazyHeaders.Builder() + headerMap.forEach {(key, value) -> + Headers.addHeader(key, value) + } + glideUrl = GlideUrl(url, Headers.build()) + } + return glideUrl + } + data class UrlOption( val method: String?, val charset: String?, 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 7315bdddc..ce8fe76fc 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 @@ -69,7 +69,7 @@ class BookInfoEditActivity : private fun upView(book: Book) { tie_book_name.setText(book.name) tie_book_author.setText(book.author) - tie_cover_url.setText(book.getDisplayCover()) + tie_cover_url.setText(book.getDisplayCover()?.substringBefore(",")) tie_book_intro.setText(book.getDisplayIntro()) upCover() }