Skip to content

Commit

Permalink
Made notifications for PassPhrasesInRAMService silent.| #372
Browse files Browse the repository at this point in the history
  • Loading branch information
DenBond7 committed May 27, 2021
1 parent 452f6f6 commit 5331914
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PassPhrasesInRAMService : BaseLifecycleService() {

val notification: Notification = Notification.Builder(
this,
NotificationChannelManager.CHANNEL_ID_SYSTEM
NotificationChannelManager.CHANNEL_ID_SILENT
)
.setContentTitle(getString(R.string.active_passphrase_session))
.setSmallIcon(R.drawable.ic_baseline_password_24dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ object NotificationChannelManager {
const val CHANNEL_ID_SYSTEM = "System"
const val CHANNEL_ID_ERRORS = "Errors"
const val CHANNEL_ID_SYNC = "Sync"
const val CHANNEL_ID_SILENT = "Silent"

/**
* Register [NotificationChannel](s) of the app in the system.
Expand All @@ -38,6 +39,7 @@ object NotificationChannelManager {
notificationManager.createNotificationChannel(genMsgsNotificationChannel(context))
notificationManager.createNotificationChannel(genErrorNotificationChannel(context))
notificationManager.createNotificationChannel(genSyncNotificationChannel(context))
notificationManager.createNotificationChannel(genSilentNotificationChannel(context))
}

/**
Expand Down Expand Up @@ -86,7 +88,7 @@ object NotificationChannelManager {
*/
private fun genGeneralNotificationChannel(context: Context): NotificationChannel {
val name = context.getString(R.string.system)
val description = context.getString(R.string.system_notifications_notification_chanel)
val description = context.getString(R.string.system_notifications_notification_channel)
val importance = NotificationManager.IMPORTANCE_DEFAULT

val notificationChannel = NotificationChannel(CHANNEL_ID_SYSTEM, name, importance)
Expand All @@ -105,7 +107,7 @@ object NotificationChannelManager {
*/
private fun genErrorNotificationChannel(context: Context): NotificationChannel {
val name = context.getString(R.string.errors_notifications)
val description = context.getString(R.string.errors_notifications_notification_chanel)
val description = context.getString(R.string.errors_notifications_notification_channel)
val importance = NotificationManager.IMPORTANCE_HIGH

val notificationChannel = NotificationChannel(CHANNEL_ID_ERRORS, name, importance)
Expand All @@ -124,7 +126,7 @@ object NotificationChannelManager {
*/
private fun genSyncNotificationChannel(context: Context): NotificationChannel {
val name = context.getString(R.string.sync)
val description = context.getString(R.string.sync_notifications_notification_chanel)
val description = context.getString(R.string.sync_notifications_notification_channel)
val importance = NotificationManager.IMPORTANCE_LOW

val notificationChannel = NotificationChannel(CHANNEL_ID_SYNC, name, importance)
Expand All @@ -134,4 +136,21 @@ object NotificationChannelManager {

return notificationChannel
}

/**
* Generate silent notification channel.
*
* @param context Interface to global information about an application environment.
* @return Generated [NotificationChannel]
*/
private fun genSilentNotificationChannel(context: Context): NotificationChannel {
val name = context.getString(R.string.silent)
val description = context.getString(R.string.silent_notifications_notification_channel)
val importance = NotificationManager.IMPORTANCE_LOW

val notificationChannel = NotificationChannel(CHANNEL_ID_SILENT, name, importance)
notificationChannel.description = description

return notificationChannel
}
}
8 changes: 5 additions & 3 deletions FlowCrypt/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@
<string name="show_cc_bcc">Show CC/BCC</string>
<string name="system">System</string>
<string name="errors_notifications">Errors notifications</string>
<string name="system_notifications_notification_chanel">The system notifications channel</string>
<string name="errors_notifications_notification_chanel">The errors notifications channel with high priority</string>
<string name="sync_notifications_notification_chanel">The sync notifications channel</string>
<string name="system_notifications_notification_channel">The system notifications channel</string>
<string name="errors_notifications_notification_channel">The errors notifications channel with high priority</string>
<string name="sync_notifications_notification_channel">The sync notifications channel</string>
<string name="warning_passphrase_is_too_weak">Your private key pass phrase is too weak. Please change it in the
settings.</string>
<string name="please_type_key_id_or_email">Please type key id or email</string>
Expand Down Expand Up @@ -508,4 +508,6 @@
<string name="passphrase_purged_from_memory">Pass phrase purged from memory</string>
<string name="no_details_about_given_key">There are no details about the given key</string>
<string name="active_passphrase_session">Active pass phrase session</string>
<string name="silent">Silent</string>
<string name="silent_notifications_notification_channel">The silent notifications channel</string>
</resources>

0 comments on commit 5331914

Please sign in to comment.