mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
Compare commits
6 Commits
5a02ce08f4
...
98edf750d7
Author | SHA1 | Date | |
---|---|---|---|
|
98edf750d7 | ||
|
2aed021e08 | ||
|
06d486c96c | ||
|
a35b7737aa | ||
|
9edc02f696 | ||
|
d1af37e04b |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
|||
local.properties
|
||||
.DS_Store
|
||||
/build
|
||||
build/
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/release
|
||||
|
|
|
@ -284,14 +284,6 @@ data class Book(
|
|||
}
|
||||
}
|
||||
|
||||
fun getBookSource(): BookSource? {
|
||||
return appDb.bookSourceDao.getBookSource(origin)
|
||||
}
|
||||
|
||||
fun isLocalModified(): Boolean {
|
||||
return isLocal && LocalBook.getLastModified(this).getOrDefault(0L) > latestChapterTime
|
||||
}
|
||||
|
||||
fun toSearchBook() = SearchBook(
|
||||
name = name,
|
||||
author = author,
|
||||
|
|
|
@ -73,7 +73,7 @@ object AppWebDav {
|
|||
WebDav(bookProgressUrl, mAuthorization).makeAsDir()
|
||||
WebDav(exportsWebDavUrl, mAuthorization).makeAsDir()
|
||||
WebDav(bgWebDavUrl, mAuthorization).makeAsDir()
|
||||
val rootBooksUrl = "${rootWebDavUrl}books"
|
||||
val rootBooksUrl = "${rootWebDavUrl}books/"
|
||||
defaultBookWebDav = RemoteBookWebDav(rootBooksUrl, mAuthorization)
|
||||
authorization = mAuthorization
|
||||
}
|
||||
|
|
|
@ -5,17 +5,26 @@ package io.legado.app.help.book
|
|||
import android.net.Uri
|
||||
import com.script.SimpleBindings
|
||||
import com.script.rhino.RhinoScriptEngine
|
||||
import io.legado.app.constant.*
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.constant.BookSourceType
|
||||
import io.legado.app.constant.BookType
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.BaseBook
|
||||
import io.legado.app.data.entities.Book
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.model.localBook.LocalBook
|
||||
import io.legado.app.utils.FileDoc
|
||||
import io.legado.app.utils.exists
|
||||
import io.legado.app.utils.find
|
||||
import io.legado.app.utils.inputStream
|
||||
import io.legado.app.utils.isUri
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import splitties.init.appCtx
|
||||
import java.io.File
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.collections.set
|
||||
|
||||
|
||||
val Book.isAudio: Boolean
|
||||
|
@ -223,6 +232,14 @@ fun Book.sync(oldBook: Book) {
|
|||
canUpdate = curBook.canUpdate
|
||||
}
|
||||
|
||||
fun Book.getBookSource(): BookSource? {
|
||||
return appDb.bookSourceDao.getBookSource(origin)
|
||||
}
|
||||
|
||||
fun Book.isLocalModified(): Boolean {
|
||||
return isLocal && LocalBook.getLastModified(this).getOrDefault(0L) > latestChapterTime
|
||||
}
|
||||
|
||||
fun Book.isSameNameAuthor(other: Any?): Boolean {
|
||||
if (other is BaseBook) {
|
||||
return name == other.name && author == other.author
|
||||
|
|
|
@ -178,13 +178,14 @@ open class WebDav(
|
|||
//依然是优化支持 caddy 自建的 WebDav ,其目录后缀都为“/”, 所以删除“/”的判定,不然无法获取该目录项
|
||||
val href = element.findNS("href", ns)[0].text().replace("+", "%2B")
|
||||
val hrefDecode = URLDecoder.decode(href, "UTF-8")
|
||||
.removeSuffix("/")
|
||||
val fileName = hrefDecode.substringAfterLast("/")
|
||||
val webDavFile: WebDav
|
||||
try {
|
||||
val urlName = hrefDecode.ifEmpty {
|
||||
url.file.replace("/", "")
|
||||
}
|
||||
val displayName = element
|
||||
.findNS("displayname", ns)
|
||||
.firstOrNull()?.text().orEmpty()
|
||||
val contentType = element
|
||||
.findNS("getcontenttype", ns)
|
||||
.firstOrNull()?.text().orEmpty()
|
||||
|
@ -206,7 +207,7 @@ open class WebDav(
|
|||
webDavFile = WebDavFile(
|
||||
fullURL,
|
||||
authorization,
|
||||
displayName = fileName,
|
||||
displayName = displayName,
|
||||
urlName = urlName,
|
||||
size = size,
|
||||
contentType = contentType,
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.legado.app.data.entities.Book
|
|||
import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.help.book.ContentProcessor
|
||||
import io.legado.app.help.book.getBookSource
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.service.AudioPlayService
|
||||
import io.legado.app.utils.postEvent
|
||||
|
|
|
@ -96,12 +96,11 @@ class WebService : BaseService() {
|
|||
if (addressList.any()) {
|
||||
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
|
||||
hostAddress = notificationList.first()
|
||||
startForegroundNotification()
|
||||
} else {
|
||||
hostAddress = getString(R.string.network_connection_unavailable)
|
||||
notificationList.add(hostAddress)
|
||||
startForegroundNotification()
|
||||
}
|
||||
startForegroundNotification()
|
||||
postEvent(EventBus.WEB_SERVICE, hostAddress)
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +183,7 @@ class WebService : BaseService() {
|
|||
*/
|
||||
override fun startForegroundNotification() {
|
||||
val builder = NotificationCompat.Builder(this, AppConst.channelIdWeb)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setSmallIcon(R.drawable.ic_web_service_noti)
|
||||
.setOngoing(true)
|
||||
.setContentTitle(getString(R.string.web_service))
|
||||
|
@ -196,7 +196,6 @@ class WebService : BaseService() {
|
|||
getString(R.string.cancel),
|
||||
servicePendingIntent<WebService>(IntentAction.stop)
|
||||
)
|
||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
val notification = builder.build()
|
||||
startForeground(NotificationId.WebService, notification)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.legado.app.data.appDb
|
|||
import io.legado.app.data.entities.Book
|
||||
import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.data.entities.BookSource
|
||||
import io.legado.app.help.book.getBookSource
|
||||
import io.legado.app.help.book.removeType
|
||||
import io.legado.app.model.AudioPlay
|
||||
import io.legado.app.model.AudioPlay.durChapter
|
||||
|
|
|
@ -1304,7 +1304,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||
when (dialogId) {
|
||||
TEXT_COLOR -> {
|
||||
setCurTextColor(color)
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 9, 11))
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(2, 6, 9, 11))
|
||||
}
|
||||
|
||||
BG_COLOR -> {
|
||||
|
@ -1500,9 +1500,9 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||
5 -> if (isInitFinish) ReadBook.loadContent(resetPageOffset = false)
|
||||
6 -> readView.upContent(resetPageOffset = false)
|
||||
8 -> ChapterProvider.upStyle()
|
||||
9 -> binding.readView.invalidateTextPage()
|
||||
9 -> readView.invalidateTextPage()
|
||||
10 -> ChapterProvider.upLayout()
|
||||
11 -> binding.readView.submitRenderTask()
|
||||
11 -> readView.submitRenderTask()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1543,10 +1543,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||
viewModel.searchResultList = it
|
||||
}
|
||||
observeEvent<Boolean>(EventBus.UPDATE_READ_ACTION_BAR) {
|
||||
binding.readMenu.reset()
|
||||
readMenu.reset()
|
||||
}
|
||||
observeEvent<Boolean>(EventBus.UP_SEEK_BAR) {
|
||||
binding.readMenu.upSeekBar()
|
||||
readMenu.upSeekBar()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.legado.app.help.AppWebDav
|
|||
import io.legado.app.help.book.BookHelp
|
||||
import io.legado.app.help.book.ContentProcessor
|
||||
import io.legado.app.help.book.isLocal
|
||||
import io.legado.app.help.book.isLocalModified
|
||||
import io.legado.app.help.book.removeType
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book
|
|||
import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.help.book.BookContent
|
||||
import io.legado.app.help.book.BookHelp
|
||||
import io.legado.app.help.book.getBookSource
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
|
|
|
@ -194,10 +194,10 @@ object NetworkUtils {
|
|||
enumeration = NetworkInterface.getNetworkInterfaces()
|
||||
} catch (e: SocketException) {
|
||||
e.printOnDebug()
|
||||
return mutableListOf()
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
var fallbackAddress: MutableList<InetAddress> = mutableListOf()
|
||||
val addressList = mutableListOf<InetAddress>()
|
||||
|
||||
while (enumeration.hasMoreElements()) {
|
||||
val nif = enumeration.nextElement()
|
||||
|
@ -205,13 +205,11 @@ object NetworkUtils {
|
|||
while (addresses.hasMoreElements()) {
|
||||
val address = addresses.nextElement()
|
||||
if (!address.isLoopbackAddress && isIPv4Address(address.hostAddress)) {
|
||||
if (nif.name?.startsWith("wlan") == true) {
|
||||
fallbackAddress.add(address)
|
||||
}
|
||||
addressList.add(address)
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallbackAddress
|
||||
return addressList
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ quickChineseTransfer = "0.2.13"
|
|||
room = "2.6.1"
|
||||
splitties = "3.0.0"
|
||||
|
||||
activity = "1.8.2"
|
||||
activity = "1.9.0"
|
||||
kotlinxSerialization = "1.6.3"
|
||||
swiperefreshlayout = "1.1.0"
|
||||
viewpager2 = "1.0.0"
|
||||
|
|
Loading…
Reference in New Issue
Block a user