diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-11-06 08:14:27 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-11-06 08:14:27 +0000 |
commit | 9d55978063947d5865bb3fa4e0c2ebef78f78812 (patch) | |
tree | 49a07707f82375dc9d5d1048a07bbdf866bffe67 /app/src/main/java/foundation/e/advancedprivacy/Notifications.kt | |
parent | 0312ce64f85b5530a00bdc72eb310ba9dc1de05b (diff) | |
download | advanced-privacy-9d55978063947d5865bb3fa4e0c2ebef78f78812.tar.gz |
epic18: Manage VPN services for Tor or Tracker control
Diffstat (limited to 'app/src/main/java/foundation/e/advancedprivacy/Notifications.kt')
-rw-r--r-- | app/src/main/java/foundation/e/advancedprivacy/Notifications.kt | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt b/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt index 639ede4..430e9d5 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/Notifications.kt @@ -29,8 +29,7 @@ import foundation.e.advancedprivacy.domain.entities.CHANNEL_FAKE_LOCATION_FLAG import foundation.e.advancedprivacy.domain.entities.CHANNEL_FIRST_BOOT import foundation.e.advancedprivacy.domain.entities.CHANNEL_IPSCRAMBLING_FLAG import foundation.e.advancedprivacy.domain.entities.CHANNEL_TRACKER_FLAG -import foundation.e.advancedprivacy.domain.entities.FeatureServiceState -import foundation.e.advancedprivacy.domain.entities.MainFeatures +import foundation.e.advancedprivacy.domain.entities.FeatureState import foundation.e.advancedprivacy.domain.entities.NOTIFICATION_FAKE_LOCATION_FLAG import foundation.e.advancedprivacy.domain.entities.NOTIFICATION_FIRST_BOOT import foundation.e.advancedprivacy.domain.entities.NOTIFICATION_IPSCRAMBLING_FLAG @@ -98,19 +97,19 @@ object Notifications { getQuickPrivacyStateUseCase.isLocationHidden.onEach { if (it) { - showFlagNotification(appContext, MainFeatures.FAKE_LOCATION) + showFlagNotification(appContext, NOTIFICATION_FAKE_LOCATION_FLAG) } else { - hideFlagNotification(appContext, MainFeatures.FAKE_LOCATION) + hideFlagNotification(appContext, NOTIFICATION_FAKE_LOCATION_FLAG) } }.launchIn(appScope) getQuickPrivacyStateUseCase.ipScramblingMode.map { - it != FeatureServiceState.OFF + it != FeatureState.OFF }.distinctUntilChanged().onEach { if (it) { - showFlagNotification(appContext, MainFeatures.IP_SCRAMBLING) + showFlagNotification(appContext, NOTIFICATION_IPSCRAMBLING_FLAG) } else { - hideFlagNotification(appContext, MainFeatures.IP_SCRAMBLING) + hideFlagNotification(appContext, NOTIFICATION_IPSCRAMBLING_FLAG) } }.launchIn(appScope) } @@ -139,9 +138,9 @@ object Notifications { NotificationManagerCompat.from(context).createNotificationChannel(channel) } - private fun showFlagNotification(context: Context, feature: MainFeatures) { - when (feature) { - MainFeatures.FAKE_LOCATION -> showFlagNotification( + private fun showFlagNotification(context: Context, id: Int) { + when (id) { + NOTIFICATION_FAKE_LOCATION_FLAG -> showFlagNotification( context = context, id = NOTIFICATION_FAKE_LOCATION_FLAG, content = NotificationContent( @@ -154,7 +153,7 @@ object Notifications { .createPendingIntent() ) ) - MainFeatures.IP_SCRAMBLING -> showFlagNotification( + NOTIFICATION_IPSCRAMBLING_FLAG -> showFlagNotification( context = context, id = NOTIFICATION_IPSCRAMBLING_FLAG, content = NotificationContent( @@ -183,12 +182,7 @@ object Notifications { NotificationManagerCompat.from(context).notify(id, builder.build()) } - private fun hideFlagNotification(context: Context, feature: MainFeatures) { - val id = when (feature) { - MainFeatures.FAKE_LOCATION -> NOTIFICATION_FAKE_LOCATION_FLAG - MainFeatures.IP_SCRAMBLING -> NOTIFICATION_IPSCRAMBLING_FLAG - else -> return - } + private fun hideFlagNotification(context: Context, id: Int) { NotificationManagerCompat.from(context).cancel(id) } } |