mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
Compare commits
No commits in common. "c53e7897624a14a374b127bc2ccd10abcde3b049" and "17416e06f630787a7e1fe402125582ec6f8d84bd" have entirely different histories.
c53e789762
...
17416e06f6
@ -7,6 +7,7 @@ import android.net.wifi.WifiManager
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.BaseService
|
import io.legado.app.base.BaseService
|
||||||
import io.legado.app.constant.AppConst
|
import io.legado.app.constant.AppConst
|
||||||
@ -22,7 +23,6 @@ import io.legado.app.utils.postEvent
|
|||||||
import io.legado.app.utils.printOnDebug
|
import io.legado.app.utils.printOnDebug
|
||||||
import io.legado.app.utils.sendToClip
|
import io.legado.app.utils.sendToClip
|
||||||
import io.legado.app.utils.servicePendingIntent
|
import io.legado.app.utils.servicePendingIntent
|
||||||
import io.legado.app.utils.startForegroundServiceCompat
|
|
||||||
import io.legado.app.utils.startService
|
import io.legado.app.utils.startService
|
||||||
import io.legado.app.utils.stopService
|
import io.legado.app.utils.stopService
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
@ -45,7 +45,7 @@ class WebService : BaseService() {
|
|||||||
|
|
||||||
fun startForeground(context: Context) {
|
fun startForeground(context: Context) {
|
||||||
val intent = Intent(context, WebService::class.java)
|
val intent = Intent(context, WebService::class.java)
|
||||||
context.startForegroundServiceCompat(intent)
|
ContextCompat.startForegroundService(context, intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop(context: Context) {
|
fun stop(context: Context) {
|
||||||
@ -94,13 +94,7 @@ class WebService : BaseService() {
|
|||||||
val addressList = NetworkUtils.getLocalIPAddress()
|
val addressList = NetworkUtils.getLocalIPAddress()
|
||||||
notificationList.clear()
|
notificationList.clear()
|
||||||
if (addressList.any()) {
|
if (addressList.any()) {
|
||||||
notificationList.addAll(addressList.map { address ->
|
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
|
||||||
getString(
|
|
||||||
R.string.http_ip,
|
|
||||||
address.hostAddress,
|
|
||||||
getPort()
|
|
||||||
)
|
|
||||||
})
|
|
||||||
hostAddress = notificationList.first()
|
hostAddress = notificationList.first()
|
||||||
} else {
|
} else {
|
||||||
hostAddress = getString(R.string.network_connection_unavailable)
|
hostAddress = getString(R.string.network_connection_unavailable)
|
||||||
@ -160,13 +154,7 @@ class WebService : BaseService() {
|
|||||||
httpServer?.start()
|
httpServer?.start()
|
||||||
webSocketServer?.start(1000 * 30) // 通信超时设置
|
webSocketServer?.start(1000 * 30) // 通信超时设置
|
||||||
notificationList.clear()
|
notificationList.clear()
|
||||||
notificationList.addAll(addressList.map { address ->
|
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
|
||||||
getString(
|
|
||||||
R.string.http_ip,
|
|
||||||
address.hostAddress,
|
|
||||||
getPort()
|
|
||||||
)
|
|
||||||
})
|
|
||||||
hostAddress = notificationList.first()
|
hostAddress = notificationList.first()
|
||||||
isRun = true
|
isRun = true
|
||||||
postEvent(EventBus.WEB_SERVICE, hostAddress)
|
postEvent(EventBus.WEB_SERVICE, hostAddress)
|
||||||
|
@ -13,7 +13,6 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
|
||||||
import io.legado.app.databinding.DialogEditTextBinding
|
import io.legado.app.databinding.DialogEditTextBinding
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.lib.dialogs.alert
|
import io.legado.app.lib.dialogs.alert
|
||||||
@ -23,14 +22,7 @@ import io.legado.app.lib.theme.backgroundColor
|
|||||||
import io.legado.app.ui.book.import.BaseImportBookActivity
|
import io.legado.app.ui.book.import.BaseImportBookActivity
|
||||||
import io.legado.app.ui.file.HandleFileContract
|
import io.legado.app.ui.file.HandleFileContract
|
||||||
import io.legado.app.ui.widget.SelectActionBar
|
import io.legado.app.ui.widget.SelectActionBar
|
||||||
import io.legado.app.utils.ArchiveUtils
|
import io.legado.app.utils.*
|
||||||
import io.legado.app.utils.FileDoc
|
|
||||||
import io.legado.app.utils.gone
|
|
||||||
import io.legado.app.utils.isContentScheme
|
|
||||||
import io.legado.app.utils.isUri
|
|
||||||
import io.legado.app.utils.launch
|
|
||||||
import io.legado.app.utils.putPrefInt
|
|
||||||
import io.legado.app.utils.visible
|
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -183,7 +175,6 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
|
|||||||
selectFolder.launch()
|
selectFolder.launch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> initRootPath(rootUri.path!!)
|
else -> initRootPath(rootUri.path!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,9 +291,7 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
|
|||||||
|
|
||||||
override fun startRead(fileDoc: FileDoc) {
|
override fun startRead(fileDoc: FileDoc) {
|
||||||
if (!ArchiveUtils.isArchive(fileDoc.name)) {
|
if (!ArchiveUtils.isArchive(fileDoc.name)) {
|
||||||
appDb.bookDao.getBookByFileName(fileDoc.name)?.let {
|
startReadBook(fileDoc.toString())
|
||||||
startReadBook(it.bookUrl)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
onArchiveFileClick(fileDoc)
|
onArchiveFileClick(fileDoc)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user