pull/1441/head
gedoor 3 years ago
parent 1973bf368e
commit ee3ad54dff
  1. 1
      app/src/main/assets/updateLog.md
  2. 7
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  3. 21
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt

@ -16,6 +16,7 @@
* 更新到SDK31,android 12 * 更新到SDK31,android 12
* 修复在线朗读引擎新建会替换之前已有的bug * 修复在线朗读引擎新建会替换之前已有的bug
* 修复目录界面自动跳转到顶部bug * 修复目录界面自动跳转到顶部bug
* 修复阿里云在线朗读引擎模板中获取时间的兼容性问题
**2021/11/20** **2021/11/20**

@ -15,7 +15,6 @@ import io.legado.app.utils.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import org.apache.commons.lang3.time.DateFormatUtils
import org.jsoup.Connection import org.jsoup.Connection
import org.jsoup.Jsoup import org.jsoup.Jsoup
import splitties.init.appCtx import splitties.init.appCtx
@ -25,6 +24,7 @@ import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.net.URLEncoder import java.net.URLEncoder
import java.nio.charset.Charset import java.nio.charset.Charset
import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream
@ -233,7 +233,10 @@ interface JsExtensions {
*/ */
fun timeFormatUTC(time: Long, format: String, sh: Int): String? { fun timeFormatUTC(time: Long, format: String, sh: Int): String? {
val utc = SimpleTimeZone(sh, "UTC") val utc = SimpleTimeZone(sh, "UTC")
return DateFormatUtils.format(Date(time), format, utc, null) return SimpleDateFormat(format, Locale.getDefault()).run {
timeZone = utc
format(Date(time))
}
} }
/** /**

@ -54,7 +54,12 @@ inline fun <reified T : Service> Context.servicePendingIntent(
val intent = Intent(this, T::class.java) val intent = Intent(this, T::class.java)
intent.action = action intent.action = action
configIntent.invoke(intent) configIntent.invoke(intent)
return getService(this, 0, intent, FLAG_UPDATE_CURRENT) val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
FLAG_UPDATE_CURRENT or FLAG_MUTABLE
} else {
FLAG_UPDATE_CURRENT
}
return getService(this, 0, intent, flags)
} }
@SuppressLint("UnspecifiedImmutableFlag") @SuppressLint("UnspecifiedImmutableFlag")
@ -65,7 +70,12 @@ inline fun <reified T : Activity> Context.activityPendingIntent(
val intent = Intent(this, T::class.java) val intent = Intent(this, T::class.java)
intent.action = action intent.action = action
configIntent.invoke(intent) configIntent.invoke(intent)
return getActivity(this, 0, intent, FLAG_UPDATE_CURRENT) val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
FLAG_UPDATE_CURRENT or FLAG_MUTABLE
} else {
FLAG_UPDATE_CURRENT
}
return getActivity(this, 0, intent, flags)
} }
@SuppressLint("UnspecifiedImmutableFlag") @SuppressLint("UnspecifiedImmutableFlag")
@ -76,7 +86,12 @@ inline fun <reified T : BroadcastReceiver> Context.broadcastPendingIntent(
val intent = Intent(this, T::class.java) val intent = Intent(this, T::class.java)
intent.action = action intent.action = action
configIntent.invoke(intent) configIntent.invoke(intent)
return getBroadcast(this, 0, intent, FLAG_CANCEL_CURRENT) val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
FLAG_UPDATE_CURRENT or FLAG_MUTABLE
} else {
FLAG_UPDATE_CURRENT
}
return getBroadcast(this, 0, intent, flags)
} }
val Context.defaultSharedPreferences: SharedPreferences val Context.defaultSharedPreferences: SharedPreferences

Loading…
Cancel
Save