Fix Vivo NPE quirk.
This commit is contained in:
parent
08556b111b
commit
4a8083f7b1
2 changed files with 14 additions and 6 deletions
|
@ -8,6 +8,7 @@ import android.net.Uri
|
|||
import android.text.SpannableStringBuilder
|
||||
import androidx.core.app.TaskStackBuilder
|
||||
import org.signal.core.util.PendingIntentFlags
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.contacts.TurnOffContactJoinedNotificationsActivity
|
||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto
|
||||
|
@ -26,6 +27,7 @@ import org.thoughtcrime.securesms.service.KeyCachingService
|
|||
import org.thoughtcrime.securesms.stories.StoryViewerArgs
|
||||
import org.thoughtcrime.securesms.stories.viewer.StoryViewerActivity
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import java.lang.NullPointerException
|
||||
|
||||
/**
|
||||
* Encapsulate all the notifications for a given conversation (thread) and the top
|
||||
|
@ -113,7 +115,7 @@ data class NotificationConversation(
|
|||
return messageCount == other.messageCount && notificationItems.zip(other.notificationItems).all { (item, otherItem) -> item.hasSameContent(otherItem) }
|
||||
}
|
||||
|
||||
fun getPendingIntent(context: Context): PendingIntent {
|
||||
fun getPendingIntent(context: Context): PendingIntent? {
|
||||
val intent: Intent = if (thread.groupStoryId != null) {
|
||||
StoryViewerActivity.createIntent(
|
||||
context,
|
||||
|
@ -131,9 +133,15 @@ data class NotificationConversation(
|
|||
.build()
|
||||
}.makeUniqueToPreventMerging()
|
||||
|
||||
return TaskStackBuilder.create(context)
|
||||
.addNextIntentWithParentStack(intent)
|
||||
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)!!
|
||||
return try {
|
||||
TaskStackBuilder.create(context)
|
||||
.addNextIntentWithParentStack(intent)
|
||||
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
} catch (e: NullPointerException) {
|
||||
Log.w(NotificationFactory.TAG, "Vivo device quirk sometimes throws NPE", e)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
PendingIntent.getActivity(context, 0, intent, PendingIntentFlags.updateCurrent())
|
||||
}
|
||||
}
|
||||
|
||||
fun getDeleteIntent(context: Context): PendingIntent? {
|
||||
|
|
|
@ -32,13 +32,13 @@ import org.thoughtcrime.securesms.util.ConversationUtil
|
|||
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
private val TAG = Log.tag(NotificationFactory::class.java)
|
||||
|
||||
/**
|
||||
* Given a notification state consisting of conversations of messages, show appropriate system notifications.
|
||||
*/
|
||||
object NotificationFactory {
|
||||
|
||||
val TAG = Log.tag(NotificationFactory::class.java)
|
||||
|
||||
fun notify(
|
||||
context: Context,
|
||||
state: NotificationStateV2,
|
||||
|
|
Loading…
Add table
Reference in a new issue