Compare commits

...

8 Commits

Author SHA1 Message Date
kunfei
c8e178c3ac
Merge 6c9a8a74bd into 9247d56cbd 2024-05-27 16:14:07 +08:00
Horis
9247d56cbd 优化 2024-05-27 16:13:29 +08:00
Horis
d774b2df7c 优化 2024-05-27 15:56:32 +08:00
Horis
17d187b4af 优化 2024-05-27 12:49:41 +08:00
Horis
df512234e6 优化 2024-05-27 10:59:54 +08:00
Horis
065ac7e119 优化 2024-05-27 10:38:04 +08:00
Xwite
6c9a8a74bd Bump cronet from 123.0.6312.80 to 125.0.6422.113
- Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/123.0.6312.80..125.0.6422.113)
2024-05-27 01:30:56 +00:00
Horis
4c6ec35d95 优化 2024-05-25 12:18:51 +08:00
28 changed files with 143 additions and 34 deletions

View File

@ -113,6 +113,14 @@
-identifiernamestring class * {
@org.chromium.build.annotations.IdentifierNameString *;
}
# Mark fields with this to help R8 figure out that they cannot be null.
-assumenosideeffects class ** {
@org.chromium.build.annotations.AssumeNonNull *** *(...) return _NONNULL_;
}
-assumenosideeffects class ** {
@org.chromium.build.annotations.AssumeNonNull *** * return _NONNULL_;
}
# -------- Config Path: components/cronet/android/cronet_impl_common_proguard.cfg --------
# Proguard config for apps that depend on cronet_impl_common_java.jar.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
{"arm64-v8a":"bbf2c50d1ebf0763d451b08e290a3244","armeabi-v7a":"ecb872f7b1b5342f4d7c36262bec0600","x86":"4da4832b89e2412d808c5b1ecdc24e3d","x86_64":"62080f051db02ed0e939affb39ce67fb","version":"123.0.6312.80"}
{"x86":"2aad90238c23fd16cd4f00932cc8bbfc","arm64-v8a":"44ea67de5cfb2fb4e9491efce9496e2f","armeabi-v7a":"52826628a666ad0f4b14ef602af85341","x86_64":"146de0053930fdabdb481fd9462fd1a7","version":"125.0.6422.113"}

View File

@ -13,6 +13,7 @@
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
**2024/02/27**
* 更新cronet: 125.0.6422.113
* 更新cronet: 123.0.6312.80
* 更新cronet: 123.0.6312.40

View File

@ -33,7 +33,7 @@ abstract class BaseService : LifecycleService() {
override fun onCreate() {
super.onCreate()
LifecycleHelp.onServiceCreate(this)
checkNotificationPermission()
checkPermission()
}
@CallSuper
@ -71,9 +71,9 @@ abstract class BaseService : LifecycleService() {
}
/**
* 检测通知权限
* 检测通知权限和后台权限
*/
private fun checkNotificationPermission() {
private fun checkPermission() {
PermissionsCompat.Builder()
.addPermissions(Permissions.POST_NOTIFICATIONS)
.rationale(R.string.notification_permission_rationale)
@ -83,5 +83,9 @@ abstract class BaseService : LifecycleService() {
}
}
.request()
PermissionsCompat.Builder()
.addPermissions(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
.rationale(R.string.ignore_battery_permission_rationale)
.request()
}
}

View File

@ -1,5 +1,6 @@
package io.legado.app.lib.permission
import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Build
@ -24,6 +25,7 @@ class PermissionActivity : AppCompatActivity() {
finish()
}
@SuppressLint("BatteryLife")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val rationale = intent.getStringExtra(KEY_RATIONALE)
@ -72,6 +74,16 @@ class PermissionActivity : AppCompatActivity() {
}
}
}
Request.TYPE_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS -> showSettingDialog(
permissions, rationale
) {
kotlin.runCatching {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
intent.setData(Uri.parse("package:$packageName"))
settingActivityResult.launch(intent)
}
}
}
onBackPressedDispatcher.addCallback(this) {

View File

@ -43,6 +43,9 @@ object Permissions {
const val ACCESS_MEDIA_LOCATION = "android.permission.ACCESS_MEDIA_LOCATION"
const val REQUEST_IGNORE_BATTERY_OPTIMIZATIONS =
"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"
object Group {
val STORAGE = if (isManageExternalStorage()) {
arrayOf(MANAGE_EXTERNAL_STORAGE)

View File

@ -9,6 +9,7 @@ import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import io.legado.app.utils.startActivity
import splitties.init.appCtx
import splitties.systemservices.powerManager
@Suppress("MemberVisibilityCanBePrivate")
internal class Request : OnRequestPermissionsResultCallback {
@ -73,6 +74,10 @@ internal class Request : OnRequestPermissionsResultCallback {
}
} else if (deniedPermissions.contains(Permissions.POST_NOTIFICATIONS)) {
toNotificationSetting()
} else if (deniedPermissions.contains(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
toIgnoreBatterySetting()
}
} else if (deniedPermissions.size > 1) {
appCtx.startActivity<PermissionActivity> {
putExtra(PermissionActivity.KEY_RATIONALE, rationale)
@ -98,6 +103,7 @@ internal class Request : OnRequestPermissionsResultCallback {
deniedPermissionList.add(permission)
}
}
Permissions.MANAGE_EXTERNAL_STORAGE -> {
if (Permissions.isManageExternalStorage()) {
if (!Environment.isExternalStorageManager()) {
@ -105,6 +111,15 @@ internal class Request : OnRequestPermissionsResultCallback {
}
}
}
Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!powerManager.isIgnoringBatteryOptimizations(appCtx.packageName)) {
deniedPermissionList.add(permission)
}
}
}
else -> {
if (
ContextCompat.checkSelfPermission(appCtx, permission)
@ -165,6 +180,18 @@ internal class Request : OnRequestPermissionsResultCallback {
}
}
private fun toIgnoreBatterySetting() {
appCtx.startActivity<PermissionActivity> {
putExtra(PermissionActivity.KEY_RATIONALE, rationale)
putExtra(
PermissionActivity.KEY_INPUT_REQUEST_TYPE,
TYPE_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
)
putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS_CODE, requestCode)
putExtra(PermissionActivity.KEY_INPUT_PERMISSIONS, deniedPermissions)
}
}
override fun onRequestPermissionsResult(
permissions: Array<String>,
grantResults: IntArray
@ -196,5 +223,6 @@ internal class Request : OnRequestPermissionsResultCallback {
const val TYPE_REQUEST_SETTING = 2
const val TYPE_MANAGE_ALL_FILES_ACCESS = 3
const val TYPE_REQUEST_NOTIFICATIONS = 4
const val TYPE_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = 5
}
}

View File

@ -3,7 +3,6 @@ package io.legado.app.model
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.core.content.ContextCompat
import io.legado.app.constant.AppLog
import io.legado.app.constant.EventBus
import io.legado.app.constant.IntentAction
@ -16,6 +15,7 @@ import io.legado.app.service.TTSReadAloudService
import io.legado.app.utils.LogUtils
import io.legado.app.utils.StringUtils
import io.legado.app.utils.postEvent
import io.legado.app.utils.startForegroundServiceCompat
import io.legado.app.utils.toastOnUi
import splitties.init.appCtx
@ -56,7 +56,7 @@ object ReadAloud {
intent.putExtra("startPos", startPos)
LogUtils.d("ReadAloud", intent.toString())
try {
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
} catch (e: Exception) {
val msg = "启动朗读服务出错\n${e.localizedMessage}"
AppLog.put(msg, e)
@ -81,7 +81,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.pause
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -89,7 +89,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.resume
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -97,7 +97,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.stop
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -105,7 +105,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.prevParagraph
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -113,7 +113,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.nextParagraph
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -121,7 +121,7 @@ object ReadAloud {
if (BaseReadAloudService.isRun) {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.upTtsSpeechRate
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}
@ -130,7 +130,7 @@ object ReadAloud {
val intent = Intent(context, aloudClass)
intent.action = IntentAction.setTimer
intent.putExtra("minute", minute)
ContextCompat.startForegroundService(context, intent)
context.startForegroundServiceCompat(intent)
}
}

View File

@ -179,6 +179,14 @@ class EpubFile(var book: Book) {
elements.select("img[src=\"cover.jpeg\"]").forEachIndexed { i, it ->
if (i > 0) it.remove()
}
elements.select("img").forEach {
if (it.attributesSize() <= 1) {
return@forEach
}
val src = it.attr("src")
it.clearAttributes()
it.attr("src", src)
}
val tag = Book.rubyTag
if (book.getDelTag(tag)) {
elements.select("rp, rt").remove()

View File

@ -168,6 +168,7 @@ abstract class BaseReadAloudService : BaseService(),
abandonFocus()
unregisterReceiver(broadcastReceiver)
postEvent(EventBus.ALOUD_STATE, Status.STOP)
notificationManager.cancel(NotificationId.ReadAloudService)
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED)
mediaSessionCompat.release()
ReadBook.uploadProgress()
@ -496,6 +497,8 @@ abstract class BaseReadAloudService : BaseService(),
nSubtitle = getString(R.string.read_aloud_s)
val builder = NotificationCompat
.Builder(this@BaseReadAloudService, AppConst.channelIdReadAloud)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
.setSmallIcon(R.drawable.ic_volume_up)
.setSubText(getString(R.string.read_aloud))
.setOngoing(true)
@ -535,7 +538,7 @@ abstract class BaseReadAloudService : BaseService(),
androidx.media.app.NotificationCompat.MediaStyle()
.setShowActionsInCompactView(0, 1, 2)
)
return builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
return builder
}
/**

View File

@ -538,7 +538,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
override fun onCleared() {
super.onCleared()
if (BaseReadAloudService.pause) {
if (BaseReadAloudService.isRun && BaseReadAloudService.pause) {
ReadAloud.stop(context)
}
}

View File

@ -200,6 +200,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
}
MotionEvent.ACTION_MOVE -> {
if (!pressDown) return true
val absX = abs(startX - event.x)
val absY = abs(startY - event.y)
if (!isMove) {

View File

@ -14,6 +14,8 @@ import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView
import androidx.core.os.bundleOf
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
@ -50,6 +52,7 @@ import io.legado.app.utils.ACache
import io.legado.app.utils.applyTint
import io.legado.app.utils.cnCompare
import io.legado.app.utils.dpToPx
import io.legado.app.utils.flowWithLifecycleFirst
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.launch
@ -68,6 +71,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.isActive
@ -98,7 +102,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
override var sortAscending = true
private set
private var snackBar: Snackbar? = null
private var isPaused = false
private val qrResult = registerForActivityResult(QrCodeResult()) {
it ?: return@registerForActivityResult
showDialogFragment(ImportBookSourceDialog(it))
@ -125,6 +128,19 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
}
}
}
private val groupMenuLifecycleOwner = object : LifecycleOwner {
private val registry = LifecycleRegistry(this)
override val lifecycle: Lifecycle get() = registry
fun onMenuOpened() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_START)
}
fun onMenuClosed() {
registry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
}
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
initRecyclerView()
@ -372,12 +388,17 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun initLiveDataGroup() {
lifecycleScope.launch {
appDb.bookSourceDao.flowGroups().conflate().collect {
groups.clear()
groups.addAll(it)
upGroupMenu()
delay(500)
}
appDb.bookSourceDao.flowGroups()
.flowWithLifecycle(lifecycle)
.flowWithLifecycleFirst(groupMenuLifecycleOwner.lifecycle)
.conflate()
.distinctUntilChanged()
.collect {
groups.clear()
groups.addAll(it)
upGroupMenu()
delay(500)
}
}
}
@ -400,6 +421,20 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
}
}
override fun onMenuOpened(featureId: Int, menu: Menu): Boolean {
if (menu === groupMenu) {
groupMenuLifecycleOwner.onMenuOpened()
}
return super.onMenuOpened(featureId, menu)
}
override fun onPanelClosed(featureId: Int, menu: Menu) {
super.onPanelClosed(featureId, menu)
if (menu === groupMenu) {
groupMenuLifecycleOwner.onMenuClosed()
}
}
private fun initSelectActionBar() {
binding.selectActionBar.setMainActionText(R.string.delete)
binding.selectActionBar.inflateMenu(R.menu.book_source_sel)
@ -637,16 +672,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
}
}
override fun onPause() {
super.onPause()
isPaused = true
}
override fun onResume() {
super.onResume()
isPaused = false
}
override fun upCountView() {
binding.selectActionBar
.upCountView(adapter.selection.size, adapter.itemCount)

View File

@ -123,6 +123,14 @@ inline fun <reified T : BroadcastReceiver> Context.broadcastPendingIntent(
return getBroadcast(this, 0, intent, flags)
}
fun Context.startForegroundServiceCompat(intent: Intent) {
try {
startService(intent)
} catch (e: IllegalStateException) {
ContextCompat.startForegroundService(this, intent)
}
}
val Context.defaultSharedPreferences: SharedPreferences
get() = PreferenceManager.getDefaultSharedPreferences(this)

View File

@ -1147,4 +1147,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1150,4 +1150,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1150,4 +1150,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1146,4 +1146,5 @@ Còn </string>
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1147,4 +1147,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1149,4 +1149,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1149,4 +1149,5 @@
<string name="font_weight_text">中/粗/细</string>
<string name="keep_swipe_tip">继续滑动以加载下一章…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -1150,4 +1150,5 @@
<string name="font_weight_text">N/B/L</string>
<string name="keep_swipe_tip">Keep swiping to load the next chapter…</string>
<string name="enable_optimize_render">启用绘制优化</string>
<string name="ignore_battery_permission_rationale">阅读需要请求后台权限以保持服务正常运行</string>
</resources>

View File

@ -42,7 +42,7 @@ android.defaults.buildfeatures.shaders=false
# and none from the library's dependencies, thereby reducing the size of the R class for that library.
android.nonTransitiveRClass=true
# https://chromiumdash.appspot.com/releases?platform=Android
CronetVersion=123.0.6312.80
CronetMainVersion=123.0.0.0
CronetVersion=125.0.6422.113
CronetMainVersion=125.0.0.0
android.injected.testOnly=false
android.nonFinalResIds=true