From cedab7f504117824d79726fae244f5d58d211224 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 22 Aug 2018 14:19:37 -0700 Subject: [PATCH] Fix migration of group names when creating Notification Channels. --- .../database/helpers/SQLCipherOpenHelper.java | 12 ++++++++++++ .../thoughtcrime/securesms/recipients/Recipient.java | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index da1c4f890b..de885d2be2 100644 --- a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -261,6 +261,18 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { String displayName = NotificationChannels.getChannelDisplayNameFor(context, systemName, profileName, address); boolean vibrateEnabled = vibrateState == 0 ? TextSecurePreferences.isNotificationVibrateEnabled(context) : vibrateState == 1; + if (address.isGroup()) { + try(Cursor groupCursor = db.rawQuery("SELECT title FROM groups WHERE group_id = ?", new String[] { address.toGroupString() })) { + if (groupCursor != null && groupCursor.moveToFirst()) { + String title = groupCursor.getString(groupCursor.getColumnIndexOrThrow("title")); + + if (!TextUtils.isEmpty(title)) { + displayName = title; + } + } + } + } + String channelId = NotificationChannels.createChannelFor(context, address, displayName, messageSoundUri, vibrateEnabled); ContentValues values = new ContentValues(1); diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index a44f9e2598..91ae3e42d1 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -17,7 +17,6 @@ */ package org.thoughtcrime.securesms.recipients; -import android.app.NotificationChannel; import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri;