diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt new file mode 100644 index 00000000..a2be569e --- /dev/null +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt @@ -0,0 +1,59 @@ +package com.artemchep.keyguard.feature.home.settings.component + +import android.content.Intent +import android.provider.Settings +import androidx.compose.foundation.layout.RowScope +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.EditNotifications +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.ui.platform.LocalContext +import com.artemchep.keyguard.common.R +import com.artemchep.keyguard.res.Res +import com.artemchep.keyguard.ui.FlatItem +import com.artemchep.keyguard.ui.icons.ChevronIcon +import com.artemchep.keyguard.ui.icons.icon +import dev.icerock.moko.resources.compose.stringResource +import kotlinx.coroutines.flow.flowOf +import org.kodein.di.DirectDI + +actual fun settingClipboardNotificationSettingsProvider( + directDI: DirectDI, +): SettingComponent = settingClipboardNotificationSettingsProvider() + +fun settingClipboardNotificationSettingsProvider( +): SettingComponent = run { + + val item = SettingIi { + SettingClipboardNotificationSettings() + } + flowOf(item) +} + +@Composable +fun SettingClipboardNotificationSettings( +) { + val updatedContext by rememberUpdatedState(LocalContext.current) + FlatItem( + leading = icon(Icons.Outlined.EditNotifications), + title = { + Text( + text = stringResource(Res.strings.pref_item_clipboard_notification_settings_title), + ) + }, + trailing = { + ChevronIcon() + }, + onClick = { + val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply { + val packageName = updatedContext.packageName + val channelId = updatedContext.getString(R.string.notification_clipboard_channel_id) + putExtra(Settings.EXTRA_APP_PACKAGE, packageName) + putExtra(Settings.EXTRA_CHANNEL_ID, channelId) + } + updatedContext.startActivity(intent) + }, + ) +} diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/SettingPaneContent.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/SettingPaneContent.kt index 977186d7..fe2edda9 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/SettingPaneContent.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/SettingPaneContent.kt @@ -40,6 +40,7 @@ import com.artemchep.keyguard.feature.home.settings.component.settingCheckTwoFAP import com.artemchep.keyguard.feature.home.settings.component.settingClearCache import com.artemchep.keyguard.feature.home.settings.component.settingClipboardAutoClearProvider import com.artemchep.keyguard.feature.home.settings.component.settingClipboardAutoRefreshProvider +import com.artemchep.keyguard.feature.home.settings.component.settingClipboardNotificationSettingsProvider import com.artemchep.keyguard.feature.home.settings.component.settingColorAccentProvider import com.artemchep.keyguard.feature.home.settings.component.settingColorSchemeProvider import com.artemchep.keyguard.feature.home.settings.component.settingConcealFieldsProvider @@ -133,6 +134,7 @@ object Setting { const val ROTATE_DEVICE_ID = "rotate_device_id" const val CLIPBOARD_AUTO_CLEAR = "clipboard_auto_clear" const val CLIPBOARD_AUTO_REFRESH = "clipboard_auto_refresh" + const val CLIPBOARD_NOTIFICATION_SETTINGS = "clipboard_notification_settings" const val CRASH = "test_crash_reports" const val CRASHLYTICS = "automatic_crash_reports" const val REQUIRE_MASTER_PASSWORD = "require_master_password" @@ -211,6 +213,7 @@ val hub = mapOf SettingComponent>( Setting.ROTATE_DEVICE_ID to ::settingRotateDeviceId, Setting.CLIPBOARD_AUTO_CLEAR to ::settingClipboardAutoClearProvider, Setting.CLIPBOARD_AUTO_REFRESH to ::settingClipboardAutoRefreshProvider, + Setting.CLIPBOARD_NOTIFICATION_SETTINGS to ::settingClipboardNotificationSettingsProvider, Setting.CRASH to ::settingCrashProvider, Setting.CRASHLYTICS to ::settingCrashlyticsProvider, Setting.REQUIRE_MASTER_PASSWORD to ::settingRequireMasterPasswordProvider, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt new file mode 100644 index 00000000..241ea501 --- /dev/null +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt @@ -0,0 +1,7 @@ +package com.artemchep.keyguard.feature.home.settings.component + +import org.kodein.di.DirectDI + +expect fun settingClipboardNotificationSettingsProvider( + directDI: DirectDI, +): SettingComponent diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/security/SecuritySettingsScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/security/SecuritySettingsScreen.kt index 4519ef4d..c179aad8 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/security/SecuritySettingsScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/security/SecuritySettingsScreen.kt @@ -21,6 +21,7 @@ fun SecuritySettingsScreen() { key = "clipboard", list = listOf( SettingPaneItem.Item(Setting.CLIPBOARD_AUTO_REFRESH), + SettingPaneItem.Item(Setting.CLIPBOARD_NOTIFICATION_SETTINGS), ), ), SettingPaneItem.Group( diff --git a/common/src/commonMain/resources/MR/base/strings.xml b/common/src/commonMain/resources/MR/base/strings.xml index 78a3c9c2..06997be3 100644 --- a/common/src/commonMain/resources/MR/base/strings.xml +++ b/common/src/commonMain/resources/MR/base/strings.xml @@ -937,6 +937,7 @@ One-time password notification duration When you autofill a login item that has a one-time password, the notification with verification code will popup for at least the defined duration Never + One-time password notification settings About Keyguard membership The Premium unlocks extra features and funds a development of the app. Thank you for supporting us! ❤️ Subscriptions diff --git a/common/src/desktopMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt b/common/src/desktopMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt new file mode 100644 index 00000000..ebc7bd34 --- /dev/null +++ b/common/src/desktopMain/kotlin/com/artemchep/keyguard/feature/home/settings/component/SettingClipboardNotificationSettings.kt @@ -0,0 +1,8 @@ +package com.artemchep.keyguard.feature.home.settings.component + +import kotlinx.coroutines.flow.flowOf +import org.kodein.di.DirectDI + +actual fun settingClipboardNotificationSettingsProvider( + directDI: DirectDI, +): SettingComponent = flowOf(null)