Updated on 2026-08-14
This commit is contained in:
parent
1d68916cb7
commit
e3357a2ed8
4 changed files with 39 additions and 0 deletions
|
|
@ -20,6 +20,21 @@ internal class IntentSettingsManager(val context: Context) : SettingsManager {
|
|||
open(intent = intent)
|
||||
}
|
||||
|
||||
override fun openAppNotificationSettings() {
|
||||
val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS).apply {
|
||||
putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName)
|
||||
}
|
||||
} else {
|
||||
Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", context.packageName, null),
|
||||
)
|
||||
}
|
||||
|
||||
open(intent = intent)
|
||||
}
|
||||
|
||||
override fun openBiometricSettings() {
|
||||
val settingsAction = when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> Settings.ACTION_BIOMETRIC_ENROLL
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.tangem.core.navigation.notifications
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Wrapper around [NotificationManagerCompat.areNotificationsEnabled] for OS-level notification toggle state.
|
||||
*
|
||||
* Reflects the user's preference in system settings (independent of runtime POST_NOTIFICATIONS permission
|
||||
* on Android 13+). Returns `false` if notifications are blocked at the OS level.
|
||||
*/
|
||||
@Singleton
|
||||
class SystemNotificationsStateProvider @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
) {
|
||||
|
||||
fun areNotificationsEnabled(): Boolean = NotificationManagerCompat.from(context).areNotificationsEnabled()
|
||||
}
|
||||
|
|
@ -2,5 +2,6 @@ package com.tangem.core.navigation.settings
|
|||
|
||||
class DummySettingsManager : SettingsManager {
|
||||
override fun openAppSettings() = Unit
|
||||
override fun openAppNotificationSettings() = Unit
|
||||
override fun openBiometricSettings() = Unit
|
||||
}
|
||||
|
|
@ -4,5 +4,7 @@ interface SettingsManager {
|
|||
|
||||
fun openAppSettings()
|
||||
|
||||
fun openAppNotificationSettings()
|
||||
|
||||
fun openBiometricSettings()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue