Skip to content

Commit 9daaa8b

Browse files
committed
UPDATE: Minor tweaks.
1 parent 063b7fa commit 9daaa8b

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/main/java/com/oasisfeng/nevo/decorators/wechat/MessagingBuilder.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ import androidx.core.app.NotificationCompat
4444
import androidx.core.app.Person
4545
import com.oasisfeng.nevo.decorators.wechat.ConversationManager.Conversation
4646
import com.oasisfeng.nevo.sdk.MutableStatusBarNotification
47-
import java.util.*
4847

4948
/**
50-
* Build the modernized [MessagingStyle] for WeChat conversation.
49+
* Build the modernized [MessagingStyle][NotificationCompat.MessagingStyle] for WeChat conversation.
5150
*
5251
* Refactored by Oasis on 2018-8-9.
5352
*/
@@ -217,7 +216,7 @@ internal class MessagingBuilder(private val mContext: Context, private val mCont
217216
}
218217

219218
fun close() {
220-
try { mContext.unregisterReceiver(mReplyReceiver) } catch (e: RuntimeException) {}
219+
try { mContext.unregisterReceiver(mReplyReceiver) } catch (_: RuntimeException) {}
221220
}
222221

223222
init {
@@ -257,16 +256,14 @@ internal class MessagingBuilder(private val mContext: Context, private val mCont
257256
}
258257

259258
private fun buildMessage(conversation: Conversation, `when`: Long, ticker: CharSequence?, text: CharSequence,
260-
sender: String?): NotificationCompat.MessagingStyle.Message {
261-
var sender = sender
259+
senderArg: String?): NotificationCompat.MessagingStyle.Message {
260+
var sender = senderArg
262261
var actualText: CharSequence? = text
263262
if (sender == null) {
264263
sender = text.extractSenderFromText()
265264
if (sender != null) {
266-
actualText =
267-
text.subSequence(sender.length + SENDER_MESSAGE_SEPARATOR.length, text.length)
268-
if (TextUtils.equals(conversation.title, sender)) sender =
269-
null // In this case, the actual sender is user itself.
265+
actualText = text.subSequence(sender.length + SENDER_MESSAGE_SEPARATOR.length, text.length)
266+
if (conversation.title == sender) sender = null // In this case, the actual sender is user itself.
270267
}
271268
}
272269
actualText = EmojiTranslator.translate(actualText)

src/main/java/com/oasisfeng/nevo/decorators/wechat/WeChatDecorator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class WeChatDecorator : NevoDecoratorService() {
8686
private fun getUser(key: String): UserHandle {
8787
val posPipe = key.indexOf('|')
8888
if (posPipe > 0)
89-
try { return userHandleOf(key.substring(0, posPipe).toInt()) } catch (e: NumberFormatException) {}
89+
try { return userHandleOf(key.substring(0, posPipe).toInt()) } catch (_: NumberFormatException) {}
9090
Log.e(TAG, "Invalid key: $key")
9191
return Process.myUserHandle() // Only correct for single user.
9292
}

0 commit comments

Comments
 (0)