diff options
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) } } |