Compare commits

...

8 Commits

Author SHA1 Message Date
dependabot[bot]
3bd97eb715
Merge d4afcbe8fd into c53e789762 2024-06-06 01:41:52 +08:00
Horis
c53e789762 优化 2024-06-05 11:04:34 +08:00
Horis
2e757ee105 优化 2024-06-04 22:38:45 +08:00
Horis
17416e06f6 优化 2024-06-04 15:21:39 +08:00
Horis
916adb7f8e 优化
#3969 #3970
2024-06-04 15:09:07 +08:00
Horis
1ba9ce009e 优化
#3968
2024-06-04 09:02:01 +08:00
Horis
697fd03cc1 优化 2024-06-02 12:50:40 +08:00
dependabot[bot]
d4afcbe8fd
Bump androidx.benchmark from 1.2.3 to 1.2.4
Bumps androidx.benchmark from 1.2.3 to 1.2.4.

---
updated-dependencies:
- dependency-name: androidx.benchmark
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 04:22:20 +00:00
6 changed files with 45 additions and 16 deletions

View File

@ -81,6 +81,10 @@ class PermissionActivity : AppCompatActivity() {
kotlin.runCatching {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
intent.setData(Uri.parse("package:$packageName"))
intent.setClassName(
"com.android.settings",
"com.android.settings.fuelgauge.RequestIgnoreBatteryOptimizations"
)
settingActivityResult.launch(intent)
}
}

View File

@ -7,7 +7,6 @@ import android.net.wifi.WifiManager
import android.os.Build
import android.os.PowerManager
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import io.legado.app.R
import io.legado.app.base.BaseService
import io.legado.app.constant.AppConst
@ -23,6 +22,7 @@ import io.legado.app.utils.postEvent
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.sendToClip
import io.legado.app.utils.servicePendingIntent
import io.legado.app.utils.startForegroundServiceCompat
import io.legado.app.utils.startService
import io.legado.app.utils.stopService
import io.legado.app.utils.toastOnUi
@ -45,7 +45,7 @@ class WebService : BaseService() {
fun startForeground(context: Context) {
val intent = Intent(context, WebService::class.java)
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
fun stop(context: Context) {
@ -94,7 +94,13 @@ class WebService : BaseService() {
val addressList = NetworkUtils.getLocalIPAddress()
notificationList.clear()
if (addressList.any()) {
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
notificationList.addAll(addressList.map { address ->
getString(
R.string.http_ip,
address.hostAddress,
getPort()
)
})
hostAddress = notificationList.first()
} else {
hostAddress = getString(R.string.network_connection_unavailable)
@ -154,7 +160,13 @@ class WebService : BaseService() {
httpServer?.start()
webSocketServer?.start(1000 * 30) // 通信超时设置
notificationList.clear()
notificationList.addAll(addressList.map { address -> getString(R.string.http_ip, address.hostAddress, getPort()) })
notificationList.addAll(addressList.map { address ->
getString(
R.string.http_ip,
address.hostAddress,
getPort()
)
})
hostAddress = notificationList.first()
isRun = true
postEvent(EventBus.WEB_SERVICE, hostAddress)

View File

@ -13,6 +13,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
@ -22,7 +23,14 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.book.import.BaseImportBookActivity
import io.legado.app.ui.file.HandleFileContract
import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.utils.*
import io.legado.app.utils.ArchiveUtils
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.Main
import kotlinx.coroutines.Job
@ -175,6 +183,7 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
selectFolder.launch()
}
}
else -> initRootPath(rootUri.path!!)
}
}
@ -291,7 +300,9 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
override fun startRead(fileDoc: FileDoc) {
if (!ArchiveUtils.isArchive(fileDoc.name)) {
startReadBook(fileDoc.toString())
appDb.bookDao.getBookByFileName(fileDoc.name)?.let {
startReadBook(it.bookUrl)
}
} else {
onArchiveFileClick(fileDoc)
}

View File

@ -278,7 +278,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (textPos.compare(selectEnd) <= 0) {
selectStart.upData(pos = textPos)
upSelectedStart(
if (textPos.columnIndex < textLine.columns.lastIndex) textColumn.start else textColumn.end,
if (textPos.columnIndex < textLine.columns.size) textColumn.start else textColumn.end,
textLine.lineBottom + relativeOffset,
textLine.lineTop + relativeOffset
)
@ -318,7 +318,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
selectEndMoveIndex(selectStart)
selectStart.upData(textPos)
upSelectedStart(
if (textPos.columnIndex < textLine.columns.lastIndex) textColumn.start else textColumn.end,
if (textPos.columnIndex < textLine.columns.size) textColumn.start else textColumn.end,
textLine.lineBottom + relativeOffset,
textLine.lineTop + relativeOffset
)
@ -498,7 +498,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
val textLine = relativePage(relativePagePos).getLine(lineIndex)
val textColumn = textLine.getColumn(charIndex)
upSelectedStart(
if (charIndex < textLine.columns.lastIndex) textColumn.start else textColumn.end,
if (charIndex < textLine.columns.size) textColumn.start else textColumn.end,
textLine.lineBottom + relativeOffset(relativePagePos),
textLine.lineTop + relativeOffset(relativePagePos)
)
@ -534,7 +534,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
}
private fun upSelectChars() {
if (!selectStart.isSelected() || !selectEnd.isSelected()) {
if (!selectStart.isSelected() && !selectEnd.isSelected()) {
return
}
val last = if (callBack.isScroll) 2 else 0
@ -621,7 +621,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (column is TextColumn) {
when {
compareStart == 0 -> {
if (textPos.columnIndex < textLine.columns.lastIndex) {
if (textPos.columnIndex < textLine.columns.size) {
builder.append(column.charData)
}
if (

View File

@ -161,7 +161,7 @@ android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
android-test = { id = "com.android.test", version.ref = "agp" }
androidx-benchmark = { id = "androidx.benchmark", version = "1.2.3" }
androidx-benchmark = { id = "androidx.benchmark", version = "1.2.4" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

View File

@ -106,11 +106,13 @@ public class PackageDocumentReader extends PackageDocumentBase {
NodeList originItemElements = manifestElement
.getElementsByTagNameNS(NAMESPACE_OPF, OPFTags.item);
for (int i = 0; i < originItemElements.getLength(); i++) {
Element itemElement = (Element) originItemElements.item(i);
fixedElements.add(itemElement);
Element itemElement = (Element) originItemElements.item(i).cloneNode(false);
String href = DOMUtil.getAttribute(itemElement, NAMESPACE_OPF, OPFAttributes.href);
String resolvedHref = packagePath.resolve(href).toString();
itemElement.setAttribute("href", resolvedHref);
fixedElements.add(itemElement);
try {
href = URLDecoder.decode(packagePath.resolve(href).toString(), Constants.CHARACTER_ENCODING);
href = URLDecoder.decode(resolvedHref, Constants.CHARACTER_ENCODING);
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.getMessage());
}
@ -177,7 +179,7 @@ public class PackageDocumentReader extends PackageDocumentBase {
.getAttribute(itemElement, NAMESPACE_OPF, OPFAttributes.href);
try {
href = URLDecoder.decode(packagePath.resolve(href).toString(), Constants.CHARACTER_ENCODING);
href = URLDecoder.decode(href, Constants.CHARACTER_ENCODING);
} catch (UnsupportedEncodingException e) {
Log.e(TAG, e.getMessage());
}