Avoid crash on notification worker (#4025)
Not quite sure why/when this happens - every stack trace is not our code, but I do get an ClassNotFoundException for Notification$Type with the new reverted code. The notification fetching (worker) then stops/crashes so I never get an Android notification. It might have something to do with https://github.com/tuskyapp/Tusky/pull/3732 ?
This commit is contained in:
parent
fa80a0123a
commit
82bc48c3ae
|
@ -249,7 +249,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
} else if (accountRequested && intent.hasExtra(NOTIFICATION_TYPE)) {
|
} else if (accountRequested && intent.hasExtra(NOTIFICATION_TYPE)) {
|
||||||
// user clicked a notification, show follow requests for type FOLLOW_REQUEST,
|
// user clicked a notification, show follow requests for type FOLLOW_REQUEST,
|
||||||
// otherwise show notification tab
|
// otherwise show notification tab
|
||||||
if (intent.getSerializableExtra(NOTIFICATION_TYPE) == Notification.Type.FOLLOW_REQUEST) {
|
if (intent.getStringExtra(NOTIFICATION_TYPE) == Notification.Type.FOLLOW_REQUEST.name) {
|
||||||
val intent = AccountListActivity.newIntent(this, AccountListActivity.Type.FOLLOW_REQUESTS)
|
val intent = AccountListActivity.newIntent(this, AccountListActivity.Type.FOLLOW_REQUESTS)
|
||||||
startActivityWithSlideInAnimation(intent)
|
startActivityWithSlideInAnimation(intent)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1102,7 +1102,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun openNotificationIntent(context: Context, tuskyAccountId: Long, type: Notification.Type): Intent {
|
fun openNotificationIntent(context: Context, tuskyAccountId: Long, type: Notification.Type): Intent {
|
||||||
return accountSwitchIntent(context, tuskyAccountId).apply {
|
return accountSwitchIntent(context, tuskyAccountId).apply {
|
||||||
putExtra(NOTIFICATION_TYPE, type)
|
putExtra(NOTIFICATION_TYPE, type.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class NotificationHelper {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
// Add the sending account's name, so it can be used when summarising this notification
|
// Add the sending account's name, so it can be used when summarising this notification
|
||||||
extras.putString(EXTRA_ACCOUNT_NAME, body.getAccount().getName());
|
extras.putString(EXTRA_ACCOUNT_NAME, body.getAccount().getName());
|
||||||
extras.putSerializable(EXTRA_NOTIFICATION_TYPE, body.getType());
|
extras.putString(EXTRA_NOTIFICATION_TYPE, body.getType().name());
|
||||||
builder.addExtras(extras);
|
builder.addExtras(extras);
|
||||||
|
|
||||||
// Only alert for the first notification of a batch to avoid multiple alerts at once
|
// Only alert for the first notification of a batch to avoid multiple alerts at once
|
||||||
|
@ -317,7 +317,8 @@ public class NotificationHelper {
|
||||||
// Create a notification that summarises the other notifications in this group
|
// Create a notification that summarises the other notifications in this group
|
||||||
|
|
||||||
// All notifications in this group have the same type, so get it from the first.
|
// All notifications in this group have the same type, so get it from the first.
|
||||||
Notification.Type notificationType = (Notification.Type)members.get(0).getNotification().extras.getSerializable(EXTRA_NOTIFICATION_TYPE);
|
String typeName = members.get(0).getNotification().extras.getString(EXTRA_NOTIFICATION_TYPE, Notification.Type.UNKNOWN.name());
|
||||||
|
Notification.Type notificationType = Notification.Type.valueOf(typeName);
|
||||||
|
|
||||||
Intent summaryResultIntent = MainActivity.openNotificationIntent(context, accountId, notificationType);
|
Intent summaryResultIntent = MainActivity.openNotificationIntent(context, accountId, notificationType);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue