Merge branch 'master' of github.com:gedoor/legado

This commit is contained in:
Xwite
2023-05-15 23:29:43 +08:00
4 changed files with 13 additions and 16 deletions
+5 -8
View File
@@ -71,8 +71,8 @@ android {
} }
applicationIdSuffix '.release' applicationIdSuffix '.release'
minifyEnabled false minifyEnabled true
//shrinkResources true shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
debug { debug {
@@ -149,7 +149,7 @@ dependencies {
//noinspection GradleDependency,DifferentStdlibGradleVersion //noinspection GradleDependency,DifferentStdlibGradleVersion
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
//协程 //协程
def coroutines_version = '1.7.0' def coroutines_version = '1.7.1'
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
@@ -157,7 +157,7 @@ dependencies {
implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3') implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
//androidX //androidX
implementation('androidx.core:core-ktx:1.10.0') implementation('androidx.core:core-ktx:1.10.1')
implementation('androidx.appcompat:appcompat:1.6.1') implementation('androidx.appcompat:appcompat:1.6.1')
implementation('androidx.activity:activity-ktx:1.7.1') implementation('androidx.activity:activity-ktx:1.7.1')
implementation('androidx.fragment:fragment-ktx:1.5.7') implementation('androidx.fragment:fragment-ktx:1.5.7')
@@ -186,9 +186,6 @@ dependencies {
// For exposing and controlling media sessions // For exposing and controlling media sessions
//implementation "androidx.media3:media3-session:$media3_version" //implementation "androidx.media3:media3-session:$media3_version"
// implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
// implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
//Splitties //Splitties
implementation("com.louiscad.splitties:splitties-appctx:$splitties_version") implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version") implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
@@ -217,7 +214,7 @@ dependencies {
//网络 //网络
implementation('com.squareup.okhttp3:okhttp:4.11.0') implementation('com.squareup.okhttp3:okhttp:4.11.0')
appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar'])) appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
appImplementation 'com.google.protobuf:protobuf-javalite:3.22.4' appImplementation 'com.google.protobuf:protobuf-javalite:3.23.0'
//Glide //Glide
def glideVersion = "4.15.1" def glideVersion = "4.15.1"
@@ -20,9 +20,9 @@ import androidx.media3.exoplayer.offline.DefaultDownloaderFactory
import androidx.media3.exoplayer.offline.DownloadRequest import androidx.media3.exoplayer.offline.DownloadRequest
import androidx.media3.exoplayer.offline.DownloaderFactory import androidx.media3.exoplayer.offline.DownloaderFactory
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.okHttpClient
import io.legado.app.utils.GSON
import okhttp3.CacheControl import okhttp3.CacheControl
import splitties.init.appCtx import splitties.init.appCtx
import java.io.File import java.io.File
@@ -30,21 +30,19 @@ import java.lang.reflect.Type
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@Suppress("unused")
@SuppressLint("UnsafeOptInUsageError") @SuppressLint("UnsafeOptInUsageError")
object ExoPlayerHelper { object ExoPlayerHelper {
private const val SPLIT_TAG = "\uD83D\uDEA7" private const val SPLIT_TAG = "\uD83D\uDEA7"
private val gson by lazy {
GsonBuilder().create()
}
private val mapType by lazy { private val mapType by lazy {
val type: Type = object : TypeToken<Map<String?, String?>?>() {}.type val type: Type = object : TypeToken<Map<String?, String?>?>() {}.type
type type
} }
fun createMediaItem(url: String, headers: Map<String, String>): MediaItem { fun createMediaItem(url: String, headers: Map<String, String>): MediaItem {
val formatUrl = url + SPLIT_TAG + gson.toJson(headers, mapType) val formatUrl = url + SPLIT_TAG + GSON.toJson(headers, mapType)
return MediaItem.Builder().setUri(formatUrl).build() return MediaItem.Builder().setUri(formatUrl).build()
} }
@@ -103,7 +101,7 @@ object ExoPlayerHelper {
val url = urls[0] val url = urls[0]
res = res.withUri(Uri.parse(url)) res = res.withUri(Uri.parse(url))
try { try {
val headers: Map<String, String> = gson.fromJson(urls[1], mapType) val headers: Map<String, String> = GSON.fromJson(urls[1], mapType)
res = res.withAdditionalHeaders(headers) res = res.withAdditionalHeaders(headers)
} catch (_: Exception) { } catch (_: Exception) {
} }
@@ -311,7 +311,7 @@ abstract class BaseReadAloudService : BaseService(),
} }
/** /**
* 断开耳机监听 * 注册多媒体按钮监听
*/ */
private fun initBroadcastReceiver() { private fun initBroadcastReceiver() {
val intentFilter = IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY) val intentFilter = IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY)
+3 -1
View File
@@ -6,7 +6,9 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx6000m # Default value: -Xmx512m -Xms256m -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError
# Bugs: This will override important JVM argument defaults. Include all important JVM arguments if you wan to change arguments. See https://github.com/gradle/gradle/issues/19750
org.gradle.jvmargs=-XX:+UseParallelGC -Xmx6g -Xms256m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects