修复:发件人昵称插入 {{接收时间}} 时转码失败(Nested Group)

优化:邮件主题、发件人昵称替换冒号、换行为 -
This commit is contained in:
pppscn 2022-06-15 14:57:23 +08:00
parent 4a81c0d0a5
commit f621237c15
2 changed files with 14 additions and 5 deletions

View File

@ -216,7 +216,7 @@ class PhoneUtils private constructor() {
val indexDuration = cursor.getColumnIndex(CallLog.Calls.DURATION)
val indexType = cursor.getColumnIndex(CallLog.Calls.TYPE)
val indexViaNumber = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && cursor.getColumnIndex("via_number") != -1) cursor.getColumnIndex("via_number") else -1
var isSimId = false
val isSimId = false
var indexSimId = -1
if (cursor.getColumnIndex("simid") != -1) {
indexSimId = cursor.getColumnIndex("simid")
@ -396,7 +396,7 @@ class PhoneUtils private constructor() {
val indexBody = cursor.getColumnIndex("body")
val indexDate = cursor.getColumnIndex("date")
val indexType = cursor.getColumnIndex("type")
var isSimId = false
val isSimId = false
var indexSimId = -1
if (cursor.getColumnIndex("sim_id") != -1) {
indexSimId = cursor.getColumnIndex("sim_id")

View File

@ -50,11 +50,15 @@ object MailUtil {
if (TextUtils.isEmpty(mail.fromNickname)) {
setFrom(InternetAddress(mail.fromAddress))
} else {
val nickname = try {
MimeUtility.encodeText(mail.fromNickname)
var nickname = mail.fromNickname.replace(":", "-").replace("\n", "-")
try {
Log.d("createMailMessage", "nickname = $nickname")
nickname = MimeUtility.encodeText(nickname)
} catch (e: UnsupportedEncodingException) {
e.printStackTrace()
}
Log.d("createMailMessage", "nickname = $nickname")
setFrom(InternetAddress("$nickname <${mail.fromAddress}>"))
}
@ -77,7 +81,12 @@ object MailUtil {
setRecipients(Message.RecipientType.BCC, bccAddress)
// 邮件主题
subject = mail.subject
subject = mail.subject.replace(":", "-").replace("\n", "-")
try {
subject = MimeUtility.encodeText(subject)
} catch (e: UnsupportedEncodingException) {
e.printStackTrace()
}
// 邮件内容
val contentPart = MimeMultipart()