mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Merge pull request #2379 from nextcloud/noid/fixToKeepNotificationChannels
fix to keep notification channels
This commit is contained in:
commit
5e7b882fba
@ -217,7 +217,7 @@ class ChatAndCallMessagingService : FirebaseMessagingService() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences)
|
val soundUri = getCallRingtoneUri(applicationContext!!, appPreferences)
|
||||||
val notificationChannelId = NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4
|
val notificationChannelId = NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name
|
||||||
val uri = Uri.parse(signatureVerification!!.user!!.baseUrl)
|
val uri = Uri.parse(signatureVerification!!.user!!.baseUrl)
|
||||||
val baseUrl = uri.host
|
val baseUrl = uri.host
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
Settings.EXTRA_CHANNEL_ID,
|
Settings.EXTRA_CHANNEL_ID,
|
||||||
NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V4
|
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name
|
||||||
)
|
)
|
||||||
|
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
@ -206,7 +206,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
Settings.EXTRA_CHANNEL_ID,
|
Settings.EXTRA_CHANNEL_ID,
|
||||||
NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES_V4
|
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
|
||||||
)
|
)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ public class NotificationWorker extends Worker {
|
|||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) {
|
if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) {
|
||||||
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES_V4);
|
notificationBuilder.setChannelId(NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// red color for the lights
|
// red color for the lights
|
||||||
|
@ -192,7 +192,11 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
|
|
||||||
private fun initNotification() {
|
private fun initNotification() {
|
||||||
mNotifyManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
mNotifyManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
mBuilder = NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_UPLOADS)
|
mBuilder = NotificationCompat.Builder(
|
||||||
|
context,
|
||||||
|
NotificationUtils.NotificationChannels
|
||||||
|
.NOTIFICATION_CHANNEL_UPLOADS.name
|
||||||
|
)
|
||||||
|
|
||||||
notification = mBuilder!!
|
notification = mBuilder!!
|
||||||
.setContentTitle(context.resources.getString(R.string.nc_upload_in_progess))
|
.setContentTitle(context.resources.getString(R.string.nc_upload_in_progess))
|
||||||
|
@ -49,19 +49,11 @@ import java.io.IOException
|
|||||||
|
|
||||||
object NotificationUtils {
|
object NotificationUtils {
|
||||||
|
|
||||||
// Notification channel IDs commented below are no longer used.
|
enum class NotificationChannels {
|
||||||
// All old notification channels get deleted when the app is upgraded to the current version.
|
NOTIFICATION_CHANNEL_MESSAGES_V4,
|
||||||
//
|
NOTIFICATION_CHANNEL_CALLS_V4,
|
||||||
// val NOTIFICATION_CHANNEL_MESSAGES = "NOTIFICATION_CHANNEL_MESSAGES"
|
NOTIFICATION_CHANNEL_UPLOADS
|
||||||
// val NOTIFICATION_CHANNEL_MESSAGES_V2 = "NOTIFICATION_CHANNEL_MESSAGES_V2"
|
}
|
||||||
// val NOTIFICATION_CHANNEL_MESSAGES_V3 = "NOTIFICATION_CHANNEL_MESSAGES_V3"
|
|
||||||
// val NOTIFICATION_CHANNEL_CALLS = "NOTIFICATION_CHANNEL_CALLS"
|
|
||||||
// val NOTIFICATION_CHANNEL_CALLS_V2 = "NOTIFICATION_CHANNEL_CALLS_V2"
|
|
||||||
// val NOTIFICATION_CHANNEL_CALLS_V3 = "NOTIFICATION_CHANNEL_CALLS_V3"
|
|
||||||
|
|
||||||
const val NOTIFICATION_CHANNEL_MESSAGES_V4 = "NOTIFICATION_CHANNEL_MESSAGES_V4"
|
|
||||||
const val NOTIFICATION_CHANNEL_CALLS_V4 = "NOTIFICATION_CHANNEL_CALLS_V4"
|
|
||||||
const val NOTIFICATION_CHANNEL_UPLOADS = "NOTIFICATION_CHANNEL_UPLOADS"
|
|
||||||
|
|
||||||
const val DEFAULT_CALL_RINGTONE_URI =
|
const val DEFAULT_CALL_RINGTONE_URI =
|
||||||
"android.resource://" + BuildConfig.APPLICATION_ID + "/raw/librem_by_feandesign_call"
|
"android.resource://" + BuildConfig.APPLICATION_ID + "/raw/librem_by_feandesign_call"
|
||||||
@ -121,7 +113,7 @@ object NotificationUtils {
|
|||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
context,
|
context,
|
||||||
Channel(
|
Channel(
|
||||||
NOTIFICATION_CHANNEL_CALLS_V4,
|
NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name,
|
||||||
context.resources.getString(R.string.nc_notification_channel_calls),
|
context.resources.getString(R.string.nc_notification_channel_calls),
|
||||||
context.resources.getString(R.string.nc_notification_channel_calls_description),
|
context.resources.getString(R.string.nc_notification_channel_calls_description),
|
||||||
true
|
true
|
||||||
@ -145,7 +137,7 @@ object NotificationUtils {
|
|||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
context,
|
context,
|
||||||
Channel(
|
Channel(
|
||||||
NOTIFICATION_CHANNEL_MESSAGES_V4,
|
NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name,
|
||||||
context.resources.getString(R.string.nc_notification_channel_messages),
|
context.resources.getString(R.string.nc_notification_channel_messages),
|
||||||
context.resources.getString(R.string.nc_notification_channel_messages_description),
|
context.resources.getString(R.string.nc_notification_channel_messages_description),
|
||||||
true
|
true
|
||||||
@ -161,7 +153,7 @@ object NotificationUtils {
|
|||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
context,
|
context,
|
||||||
Channel(
|
Channel(
|
||||||
NOTIFICATION_CHANNEL_UPLOADS,
|
NotificationChannels.NOTIFICATION_CHANNEL_UPLOADS.name,
|
||||||
context.resources.getString(R.string.nc_notification_channel_uploads),
|
context.resources.getString(R.string.nc_notification_channel_uploads),
|
||||||
context.resources.getString(R.string.nc_notification_channel_uploads_description),
|
context.resources.getString(R.string.nc_notification_channel_uploads_description),
|
||||||
false
|
false
|
||||||
@ -190,12 +182,11 @@ object NotificationUtils {
|
|||||||
notificationManager.deleteNotificationChannelGroup(channelGroup.id)
|
notificationManager.deleteNotificationChannelGroup(channelGroup.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val channelsToKeep = NotificationChannels.values().map { it.name }
|
||||||
|
|
||||||
// Delete all notification channels created by previous versions
|
// Delete all notification channels created by previous versions
|
||||||
for (channel in notificationManager.notificationChannels) {
|
for (channel in notificationManager.notificationChannels) {
|
||||||
if (
|
if (!channelsToKeep.contains(channel.id)) {
|
||||||
channel.id != NOTIFICATION_CHANNEL_CALLS_V4 &&
|
|
||||||
channel.id != NOTIFICATION_CHANNEL_MESSAGES_V4
|
|
||||||
) {
|
|
||||||
notificationManager.deleteNotificationChannel(channel.id)
|
notificationManager.deleteNotificationChannel(channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,7 +303,8 @@ object NotificationUtils {
|
|||||||
): Uri? {
|
): Uri? {
|
||||||
return getRingtoneUri(
|
return getRingtoneUri(
|
||||||
context,
|
context,
|
||||||
appPreferences.callRingtoneUri, DEFAULT_CALL_RINGTONE_URI, NOTIFICATION_CHANNEL_CALLS_V4
|
appPreferences.callRingtoneUri,
|
||||||
|
DEFAULT_CALL_RINGTONE_URI, NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +314,8 @@ object NotificationUtils {
|
|||||||
): Uri? {
|
): Uri? {
|
||||||
return getRingtoneUri(
|
return getRingtoneUri(
|
||||||
context,
|
context,
|
||||||
appPreferences.messageRingtoneUri, DEFAULT_MESSAGE_RINGTONE_URI, NOTIFICATION_CHANNEL_MESSAGES_V4
|
appPreferences.messageRingtoneUri,
|
||||||
|
DEFAULT_MESSAGE_RINGTONE_URI, NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user