From 67482187691300292141d351776f3fb5a1102ac8 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sat, 30 Dec 2023 11:33:41 +0200 Subject: [PATCH] Minor clean-up --- .../keyguard/android/PasskeyCreateActivity.kt | 10 +-- .../keyguard/android/PasskeyCreateRequest.kt | 2 +- .../keyguard/android/PasskeyGenerator.kt | 2 +- .../keyguard/android/PasskeyUtils.kt | 2 +- .../android/downloader/DownloadManagerImpl.kt | 4 +- .../journal/room/DownloadInfoEntity.kt | 2 +- .../worker/AttachmentDownloadWorker.kt | 8 +-- .../kotlin/com/artemchep/keyguard/Urls.kt | 6 ++ .../journal/room/DownloadInfoEntity2.kt | 2 +- .../passkey/entity}/CreatePasskeyRequest.kt | 2 +- .../{ui => common/util}/StringForEach.kt | 2 +- .../{ui => common/util}/getHttpCode.kt | 2 +- .../store/bitwarden/BitwardenServiceUtil.kt | 2 +- .../attachments/model/AttachmentItem.kt | 4 +- .../history/GeneratorHistoryScreen.kt | 4 +- .../home/settings/SettingPaneContent.kt | 4 +- .../settings/accounts/AccountListScreen.kt | 5 +- .../feature/home/vault/add/AddScreen.kt | 6 +- .../home/vault/component/VaultViewNoteItem.kt | 4 +- .../JustDeleteMeServiceListScreen.kt | 2 +- .../JustDeleteMeServiceViewScreen.kt | 4 +- .../largetype/LargeTypeStateProducer.kt | 2 +- .../directory/PasskeysServiceListScreen.kt | 2 +- .../directory/PasskeysServiceViewScreen.kt | 4 +- .../tfa/directory/TwoFaServiceListScreen.kt | 2 +- .../tfa/directory/TwoFaServiceViewScreen.kt | 4 +- .../bitwarden/usecase/util/RefreshToken.kt | 4 +- .../keyguard/ui/items/FlatItemShimmer.kt | 64 ------------------- .../keyguard/ui/markdown/Markdown.kt | 2 +- .../keyguard/ui/poweredby/PoweredBy.kt | 9 ++- .../artemchep/keyguard/ui/totp/formatTotp.kt | 2 +- .../keyguard/copy/DownloadManagerDesktop.kt | 5 +- 32 files changed, 52 insertions(+), 127 deletions(-) create mode 100644 common/src/commonMain/kotlin/com/artemchep/keyguard/Urls.kt rename common/src/commonMain/kotlin/com/artemchep/keyguard/{provider/bitwarden => common/service/passkey/entity}/CreatePasskeyRequest.kt (98%) rename common/src/commonMain/kotlin/com/artemchep/keyguard/{ui => common/util}/StringForEach.kt (85%) rename common/src/commonMain/kotlin/com/artemchep/keyguard/{ui => common/util}/getHttpCode.kt (97%) delete mode 100644 common/src/commonMain/kotlin/com/artemchep/keyguard/ui/items/FlatItemShimmer.kt diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateActivity.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateActivity.kt index 645eaf7b..ea40f01e 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateActivity.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateActivity.kt @@ -7,12 +7,9 @@ import android.content.Intent import android.os.Build import android.os.Bundle import androidx.annotation.RequiresApi -import androidx.compose.animation.Crossfade import androidx.compose.foundation.layout.* import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.Add import androidx.compose.material.icons.outlined.Close -import androidx.compose.material.icons.outlined.ErrorOutline import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -42,19 +39,14 @@ import com.artemchep.keyguard.feature.keyguard.ManualAppScreenOnCreate import com.artemchep.keyguard.feature.keyguard.ManualAppScreenOnLoading import com.artemchep.keyguard.feature.keyguard.ManualAppScreenOnMain import com.artemchep.keyguard.feature.keyguard.ManualAppScreenOnUnlock -import com.artemchep.keyguard.platform.crashlyticsIsEnabled import com.artemchep.keyguard.platform.recordException import com.artemchep.keyguard.platform.recordLog -import com.artemchep.keyguard.provider.bitwarden.CreatePasskey +import com.artemchep.keyguard.common.service.passkey.entity.CreatePasskey import com.artemchep.keyguard.res.Res import com.artemchep.keyguard.ui.MediumEmphasisAlpha -import com.artemchep.keyguard.ui.OtherScaffold import com.artemchep.keyguard.ui.theme.Dimens import com.artemchep.keyguard.ui.theme.combineAlpha import dev.icerock.moko.resources.compose.stringResource -import kotlinx.coroutines.async -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateRequest.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateRequest.kt index 06e513de..a96cdcc6 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateRequest.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyCreateRequest.kt @@ -11,7 +11,7 @@ import androidx.credentials.provider.ProviderCreateCredentialRequest import androidx.credentials.webauthn.Cbor import com.artemchep.keyguard.common.model.AddPasskeyCipherRequest import com.artemchep.keyguard.common.service.text.Base64Service -import com.artemchep.keyguard.provider.bitwarden.CreatePasskey +import com.artemchep.keyguard.common.service.passkey.entity.CreatePasskey import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObjectBuilder diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyGenerator.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyGenerator.kt index 63d40c01..8f54f65a 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyGenerator.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyGenerator.kt @@ -1,6 +1,6 @@ package com.artemchep.keyguard.android -import com.artemchep.keyguard.provider.bitwarden.CreatePasskeyPubKeyCredParams +import com.artemchep.keyguard.common.service.passkey.entity.CreatePasskeyPubKeyCredParams import java.security.KeyPair import java.security.KeyPairGenerator import java.security.PrivateKey diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyUtils.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyUtils.kt index 98268c46..16ec51c7 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyUtils.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/PasskeyUtils.kt @@ -7,7 +7,7 @@ import com.artemchep.keyguard.common.io.bind import com.artemchep.keyguard.common.service.crypto.CryptoGenerator import com.artemchep.keyguard.common.service.gpmprivapps.PrivilegedAppsService import com.artemchep.keyguard.common.usecase.impl.isSubdomain -import com.artemchep.keyguard.provider.bitwarden.CreatePasskeyAttestation +import com.artemchep.keyguard.common.service.passkey.entity.CreatePasskeyAttestation import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.request.get diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/DownloadManagerImpl.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/DownloadManagerImpl.kt index 9b21a4b9..0f176ca4 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/DownloadManagerImpl.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/DownloadManagerImpl.kt @@ -14,8 +14,8 @@ import com.artemchep.keyguard.common.service.download.DownloadManager import com.artemchep.keyguard.common.service.download.DownloadProgress import com.artemchep.keyguard.common.service.text.Base64Service import com.artemchep.keyguard.common.usecase.WindowCoroutineScope -import com.artemchep.keyguard.ui.CodeException -import com.artemchep.keyguard.ui.getHttpCode +import com.artemchep.keyguard.common.util.CodeException +import com.artemchep.keyguard.common.util.getHttpCode import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.Job diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity.kt index db3a86a8..5f8bb973 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity.kt @@ -2,7 +2,7 @@ package com.artemchep.keyguard.android.downloader.journal.room import androidx.room.Embedded import androidx.room.Entity -import com.artemchep.keyguard.ui.canRetry +import com.artemchep.keyguard.common.util.canRetry import kotlinx.datetime.Instant @Entity( diff --git a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/worker/AttachmentDownloadWorker.kt b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/worker/AttachmentDownloadWorker.kt index 06557401..87c928dd 100644 --- a/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/worker/AttachmentDownloadWorker.kt +++ b/common/src/androidMain/kotlin/com/artemchep/keyguard/android/downloader/worker/AttachmentDownloadWorker.kt @@ -5,8 +5,6 @@ import android.app.NotificationManager import android.app.PendingIntent import android.content.Context import android.content.pm.ServiceInfo -import android.os.Build -import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.content.getSystemService import androidx.work.BackoffPolicy @@ -18,13 +16,11 @@ import androidx.work.ForegroundInfo import androidx.work.NetworkType import androidx.work.OneTimeWorkRequestBuilder import androidx.work.Operation -import androidx.work.OutOfQuotaPolicy import androidx.work.WorkManager import androidx.work.WorkerParameters import com.artemchep.keyguard.android.Notifications import com.artemchep.keyguard.android.downloader.journal.DownloadRepository import com.artemchep.keyguard.android.downloader.receiver.AttachmentDownloadActionReceiver -import com.artemchep.keyguard.android.downloader.withId import com.artemchep.keyguard.common.R import com.artemchep.keyguard.common.io.attempt import com.artemchep.keyguard.common.io.bind @@ -33,8 +29,8 @@ import com.artemchep.keyguard.common.io.toIO import com.artemchep.keyguard.common.service.download.DownloadManager import com.artemchep.keyguard.common.service.download.DownloadProgress import com.artemchep.keyguard.feature.filepicker.humanReadableByteCountSI -import com.artemchep.keyguard.ui.canRetry -import com.artemchep.keyguard.ui.getHttpCode +import com.artemchep.keyguard.common.util.canRetry +import com.artemchep.keyguard.common.util.getHttpCode import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.last import kotlinx.coroutines.flow.onEach diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/Urls.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/Urls.kt new file mode 100644 index 00000000..a168e3fb --- /dev/null +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/Urls.kt @@ -0,0 +1,6 @@ +package com.artemchep.keyguard + +const val URL_JUST_DELETE_ME = "https://justdeleteme.xyz/" +const val URL_HAVE_I_BEEN_PWNED = "https://haveibeenpwned.com/" +const val URL_2FA = "https://2fa.directory/" +const val URL_PASSKEYS = "https://passkeys.directory/" diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity2.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity2.kt index 7cd79a87..5593a903 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity2.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/android/downloader/journal/room/DownloadInfoEntity2.kt @@ -1,6 +1,6 @@ package com.artemchep.keyguard.android.downloader.journal.room -import com.artemchep.keyguard.ui.canRetry +import com.artemchep.keyguard.common.util.canRetry import kotlinx.datetime.Instant data class DownloadInfoEntity2( diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/CreatePasskeyRequest.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/passkey/entity/CreatePasskeyRequest.kt similarity index 98% rename from common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/CreatePasskeyRequest.kt rename to common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/passkey/entity/CreatePasskeyRequest.kt index 7050a207..e8565006 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/CreatePasskeyRequest.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/passkey/entity/CreatePasskeyRequest.kt @@ -1,4 +1,4 @@ -package com.artemchep.keyguard.provider.bitwarden +package com.artemchep.keyguard.common.service.passkey.entity import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/StringForEach.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/StringForEach.kt similarity index 85% rename from common/src/commonMain/kotlin/com/artemchep/keyguard/ui/StringForEach.kt rename to common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/StringForEach.kt index 339a3f7f..8357bffe 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/StringForEach.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/StringForEach.kt @@ -1,4 +1,4 @@ -package com.artemchep.keyguard.ui +package com.artemchep.keyguard.common.util import kotlin.streams.asSequence diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/getHttpCode.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/getHttpCode.kt similarity index 97% rename from common/src/commonMain/kotlin/com/artemchep/keyguard/ui/getHttpCode.kt rename to common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/getHttpCode.kt index d5bd7338..f15ee005 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/getHttpCode.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/util/getHttpCode.kt @@ -1,4 +1,4 @@ -package com.artemchep.keyguard.ui +package com.artemchep.keyguard.common.util import com.artemchep.keyguard.common.exception.HttpException import com.artemchep.keyguard.core.store.bitwarden.BitwardenService diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/core/store/bitwarden/BitwardenServiceUtil.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/core/store/bitwarden/BitwardenServiceUtil.kt index 834cb6d4..cf16a400 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/core/store/bitwarden/BitwardenServiceUtil.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/core/store/bitwarden/BitwardenServiceUtil.kt @@ -1,6 +1,6 @@ package com.artemchep.keyguard.core.store.bitwarden -import com.artemchep.keyguard.ui.canRetry +import com.artemchep.keyguard.common.util.canRetry import io.ktor.http.HttpStatusCode import kotlinx.datetime.Instant diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/attachments/model/AttachmentItem.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/attachments/model/AttachmentItem.kt index 6d1a079d..9edb0ba7 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/attachments/model/AttachmentItem.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/attachments/model/AttachmentItem.kt @@ -3,8 +3,8 @@ package com.artemchep.keyguard.feature.attachments.model import com.artemchep.keyguard.common.service.download.DownloadProgress import com.artemchep.keyguard.feature.attachments.SelectableItemState import com.artemchep.keyguard.ui.ContextItem -import com.artemchep.keyguard.ui.canRetry -import com.artemchep.keyguard.ui.getHttpCode +import com.artemchep.keyguard.common.util.canRetry +import com.artemchep.keyguard.common.util.getHttpCode import kotlinx.coroutines.flow.StateFlow data class AttachmentItem( diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/generator/history/GeneratorHistoryScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/generator/history/GeneratorHistoryScreen.kt index 9966f988..debdf9b4 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/generator/history/GeneratorHistoryScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/generator/history/GeneratorHistoryScreen.kt @@ -42,7 +42,7 @@ import com.artemchep.keyguard.ui.OptionsButton import com.artemchep.keyguard.ui.ScaffoldLazyColumn import com.artemchep.keyguard.ui.colorizePassword import com.artemchep.keyguard.ui.icons.Stub -import com.artemchep.keyguard.ui.items.FlatItemSkeleton +import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.theme.monoFontFamily import com.artemchep.keyguard.ui.toolbar.LargeToolbar import dev.icerock.moko.resources.compose.stringResource @@ -113,7 +113,7 @@ private fun GeneratorPaneMaster( private fun LazyListScope.populateGeneratorPaneMasterSkeleton() { item("skeleton") { - FlatItemSkeleton() + SkeletonItem() } } 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 c8b11648..9c1ff219 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 @@ -88,7 +88,7 @@ import com.artemchep.keyguard.feature.home.settings.component.settingWebsiteIcon import com.artemchep.keyguard.feature.home.settings.component.settingWriteAccessProvider import com.artemchep.keyguard.feature.navigation.NavigationIcon import com.artemchep.keyguard.ui.ScaffoldLazyColumn -import com.artemchep.keyguard.ui.items.FlatItemSkeleton +import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.toolbar.LargeToolbar import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.Flow @@ -358,7 +358,7 @@ fun SettingPaneContent2( when (val contentState = state.list) { is Loadable.Loading -> { item("skeleton") { - FlatItemSkeleton() + SkeletonItem() } } diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/AccountListScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/AccountListScreen.kt index d3922dff..1d76607a 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/AccountListScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/AccountListScreen.kt @@ -1,6 +1,5 @@ package com.artemchep.keyguard.feature.home.settings.accounts -import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.lazy.items import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.icons.Icons @@ -32,8 +31,8 @@ import com.artemchep.keyguard.ui.FabState import com.artemchep.keyguard.ui.OptionsButton import com.artemchep.keyguard.ui.ScaffoldLazyColumn import com.artemchep.keyguard.ui.icons.SyncIcon -import com.artemchep.keyguard.ui.items.FlatItemSkeleton import com.artemchep.keyguard.ui.selection.SelectionBar +import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.toolbar.LargeToolbar import dev.icerock.moko.resources.compose.stringResource @@ -145,7 +144,7 @@ fun AccountListScreenContent( if (state.items.isEmpty()) { item("header") { if (state.isLoading) { - FlatItemSkeleton() + SkeletonItem() } else { EmptyView( icon = { diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/add/AddScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/add/AddScreen.kt index 911aa6f8..0766a1be 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/add/AddScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/add/AddScreen.kt @@ -4,7 +4,6 @@ package com.artemchep.keyguard.feature.home.vault.add import androidx.compose.animation.Crossfade import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -82,7 +81,6 @@ import com.artemchep.keyguard.common.model.Loadable import com.artemchep.keyguard.common.model.UsernameVariationIcon import com.artemchep.keyguard.common.model.fold import com.artemchep.keyguard.common.model.getOrNull -import com.artemchep.keyguard.common.model.title import com.artemchep.keyguard.common.model.titleH import com.artemchep.keyguard.common.service.logging.LogRepository import com.artemchep.keyguard.feature.auth.common.TextFieldModel2 @@ -135,7 +133,7 @@ import com.artemchep.keyguard.ui.icons.KeyguardOrganization import com.artemchep.keyguard.ui.icons.KeyguardTwoFa import com.artemchep.keyguard.ui.icons.KeyguardWebsite import com.artemchep.keyguard.ui.icons.icon -import com.artemchep.keyguard.ui.markdown.Md +import com.artemchep.keyguard.ui.markdown.MarkdownText import com.artemchep.keyguard.ui.shimmer.shimmer import com.artemchep.keyguard.ui.skeleton.SkeletonText import com.artemchep.keyguard.ui.skeleton.SkeletonTextField @@ -882,7 +880,7 @@ private fun NoteTextField( text = "Markdown", style = MaterialTheme.typography.titleLarge, ) - Md( + MarkdownText( modifier = Modifier .padding( horizontal = Dimens.horizontalPadding, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewNoteItem.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewNoteItem.kt index fdb67141..dda733a0 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewNoteItem.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/vault/component/VaultViewNoteItem.kt @@ -17,7 +17,7 @@ import com.artemchep.keyguard.res.Res import com.artemchep.keyguard.ui.ExpandedIfNotEmpty import com.artemchep.keyguard.ui.FlatItem import com.artemchep.keyguard.ui.icons.VisibilityIcon -import com.artemchep.keyguard.ui.markdown.Md +import com.artemchep.keyguard.ui.markdown.MarkdownText import com.artemchep.keyguard.ui.theme.Dimens import dev.icerock.moko.resources.compose.stringResource @@ -79,7 +79,7 @@ fun VaultViewNoteItem( ) { SelectionContainer { if (item.markdown) { - Md( + MarkdownText( markdown = item.text, ) } else { diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceListScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceListScreen.kt index 6ade5ed8..72490b8e 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceListScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceListScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll +import com.artemchep.keyguard.URL_JUST_DELETE_ME import com.artemchep.keyguard.common.model.Loadable import com.artemchep.keyguard.common.model.flatMap import com.artemchep.keyguard.common.model.getOrNull @@ -39,7 +40,6 @@ import com.artemchep.keyguard.ui.ScaffoldLazyColumn import com.artemchep.keyguard.ui.focus.FocusRequester2 import com.artemchep.keyguard.ui.focus.focusRequester2 import com.artemchep.keyguard.ui.icons.IconBox -import com.artemchep.keyguard.ui.poweredby.URL_JUST_DELETE_ME import com.artemchep.keyguard.ui.pulltosearch.PullToSearch import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.toolbar.CustomToolbar diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceViewScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceViewScreen.kt index 6b9ca693..81900f14 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceViewScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/justdeleteme/directory/JustDeleteMeServiceViewScreen.kt @@ -30,7 +30,7 @@ import com.artemchep.keyguard.ui.MediumEmphasisAlpha import com.artemchep.keyguard.ui.icons.ChevronIcon import com.artemchep.keyguard.ui.icons.IconBox import com.artemchep.keyguard.ui.icons.icon -import com.artemchep.keyguard.ui.markdown.Md +import com.artemchep.keyguard.ui.markdown.MarkdownText import com.artemchep.keyguard.ui.poweredby.PoweredByJustDeleteMe import com.artemchep.keyguard.ui.theme.Dimens import com.artemchep.keyguard.ui.theme.combineAlpha @@ -66,7 +66,7 @@ fun JustDeleteMeScreen( Column { val notes = args.justDeleteMe.notes if (notes != null) { - Md( + MarkdownText( modifier = Modifier .padding(horizontal = Dimens.horizontalPadding), markdown = notes, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/largetype/LargeTypeStateProducer.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/largetype/LargeTypeStateProducer.kt index e7c07c66..4e18c45c 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/largetype/LargeTypeStateProducer.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/largetype/LargeTypeStateProducer.kt @@ -5,7 +5,7 @@ import arrow.core.partially1 import com.artemchep.keyguard.common.model.Loadable import com.artemchep.keyguard.feature.navigation.state.navigatePopSelf import com.artemchep.keyguard.feature.navigation.state.produceScreenState -import com.artemchep.keyguard.ui.asCodePointsSequence +import com.artemchep.keyguard.common.util.asCodePointsSequence import kotlinx.coroutines.flow.map @Composable diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceListScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceListScreen.kt index 90cb2a19..f1c3738d 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceListScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceListScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll +import com.artemchep.keyguard.URL_PASSKEYS import com.artemchep.keyguard.common.model.Loadable import com.artemchep.keyguard.common.model.flatMap import com.artemchep.keyguard.common.model.getOrNull @@ -38,7 +39,6 @@ import com.artemchep.keyguard.ui.ScaffoldLazyColumn import com.artemchep.keyguard.ui.focus.FocusRequester2 import com.artemchep.keyguard.ui.focus.focusRequester2 import com.artemchep.keyguard.ui.icons.IconBox -import com.artemchep.keyguard.ui.poweredby.URL_PASSKEYS import com.artemchep.keyguard.ui.pulltosearch.PullToSearch import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.toolbar.CustomToolbar diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceViewScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceViewScreen.kt index 732e6ed3..2be68fbf 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceViewScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/passkeys/directory/PasskeysServiceViewScreen.kt @@ -31,7 +31,7 @@ import com.artemchep.keyguard.res.Res import com.artemchep.keyguard.ui.DisabledEmphasisAlpha import com.artemchep.keyguard.ui.MediumEmphasisAlpha import com.artemchep.keyguard.ui.icons.icon -import com.artemchep.keyguard.ui.markdown.Md +import com.artemchep.keyguard.ui.markdown.MarkdownText import com.artemchep.keyguard.ui.poweredby.PoweredByPasskeys import com.artemchep.keyguard.ui.skeleton.SkeletonText import com.artemchep.keyguard.ui.theme.Dimens @@ -130,7 +130,7 @@ fun PasskeysViewScreen( val state = loadableState.getOrNull()?.content?.getOrNull() val notes = state?.model?.notes if (notes != null) { - Md( + MarkdownText( modifier = Modifier .padding(horizontal = Dimens.horizontalPadding), markdown = notes, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceListScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceListScreen.kt index b801f024..19d36e2d 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceListScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceListScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll +import com.artemchep.keyguard.URL_2FA import com.artemchep.keyguard.common.model.Loadable import com.artemchep.keyguard.common.model.flatMap import com.artemchep.keyguard.common.model.getOrNull @@ -38,7 +39,6 @@ import com.artemchep.keyguard.ui.ScaffoldLazyColumn import com.artemchep.keyguard.ui.focus.FocusRequester2 import com.artemchep.keyguard.ui.focus.focusRequester2 import com.artemchep.keyguard.ui.icons.IconBox -import com.artemchep.keyguard.ui.poweredby.URL_2FA import com.artemchep.keyguard.ui.pulltosearch.PullToSearch import com.artemchep.keyguard.ui.skeleton.SkeletonItem import com.artemchep.keyguard.ui.toolbar.CustomToolbar diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceViewScreen.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceViewScreen.kt index ef50c022..077f3721 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceViewScreen.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/tfa/directory/TwoFaServiceViewScreen.kt @@ -37,7 +37,7 @@ import com.artemchep.keyguard.ui.MediumEmphasisAlpha import com.artemchep.keyguard.ui.icons.ChevronIcon import com.artemchep.keyguard.ui.icons.KeyguardTwoFa import com.artemchep.keyguard.ui.icons.icon -import com.artemchep.keyguard.ui.markdown.Md +import com.artemchep.keyguard.ui.markdown.MarkdownText import com.artemchep.keyguard.ui.poweredby.PoweredBy2factorauth import com.artemchep.keyguard.ui.skeleton.SkeletonText import com.artemchep.keyguard.ui.theme.Dimens @@ -137,7 +137,7 @@ fun TwoFaServiceViewScreen( val state = loadableState.getOrNull()?.content?.getOrNull() val notes = state?.model?.notes if (notes != null) { - Md( + MarkdownText( modifier = Modifier .padding(horizontal = Dimens.horizontalPadding), markdown = notes, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/usecase/util/RefreshToken.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/usecase/util/RefreshToken.kt index 1222e7a6..3fc3377e 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/usecase/util/RefreshToken.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/usecase/util/RefreshToken.kt @@ -6,8 +6,8 @@ import com.artemchep.keyguard.core.store.DatabaseManager import com.artemchep.keyguard.core.store.bitwarden.BitwardenService import com.artemchep.keyguard.core.store.bitwarden.BitwardenToken import com.artemchep.keyguard.provider.bitwarden.api.refresh -import com.artemchep.keyguard.ui.canRetry -import com.artemchep.keyguard.ui.getHttpCode +import com.artemchep.keyguard.common.util.canRetry +import com.artemchep.keyguard.common.util.getHttpCode import io.ktor.client.HttpClient import io.ktor.http.HttpStatusCode import kotlinx.coroutines.delay diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/items/FlatItemShimmer.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/items/FlatItemShimmer.kt deleted file mode 100644 index 8bf21301..00000000 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/items/FlatItemShimmer.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.artemchep.keyguard.ui.items - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.LocalContentColor -import androidx.compose.material3.MaterialTheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import com.artemchep.keyguard.ui.Avatar -import com.artemchep.keyguard.ui.DisabledEmphasisAlpha -import com.artemchep.keyguard.ui.FlatItemLayout -import com.artemchep.keyguard.ui.shimmer.shimmer - -@Composable -fun FlatItemSkeleton( - avatar: Boolean = false, - fill: Boolean = false, - titleWidthFraction: Float = 0.45f, - textWidthFraction: Float = 0.33f, -) { - val contentColor = LocalContentColor.current.copy(alpha = DisabledEmphasisAlpha) - FlatItemLayout( - modifier = Modifier - .shimmer(), - backgroundColor = contentColor - .takeIf { fill } - ?.copy( - alpha = 0.08f, - ) - ?: Color.Unspecified, - leading = if (avatar) { - // composable - { - Avatar { - } - } - } else { - null - }, - content = { - Box( - Modifier - .height(18.dp) - .fillMaxWidth(titleWidthFraction) - .clip(MaterialTheme.shapes.medium) - .background(contentColor), - ) - Box( - Modifier - .padding(top = 4.dp) - .height(14.dp) - .fillMaxWidth(textWidthFraction) - .clip(MaterialTheme.shapes.medium) - .background(contentColor), - ) - }, - ) -} diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt index 056abf4f..248cdb4e 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt @@ -10,7 +10,7 @@ import com.halilibo.richtext.ui.resolveDefaults import com.halilibo.richtext.ui.string.RichTextStringStyle @Composable -fun Md( +fun MarkdownText( modifier: Modifier = Modifier, markdown: String, ) { diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/poweredby/PoweredBy.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/poweredby/PoweredBy.kt index 2aa7f90a..261f482c 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/poweredby/PoweredBy.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/poweredby/PoweredBy.kt @@ -14,6 +14,10 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import com.artemchep.keyguard.URL_2FA +import com.artemchep.keyguard.URL_HAVE_I_BEEN_PWNED +import com.artemchep.keyguard.URL_JUST_DELETE_ME +import com.artemchep.keyguard.URL_PASSKEYS import com.artemchep.keyguard.feature.navigation.LocalNavigationController import com.artemchep.keyguard.feature.navigation.NavigationIntent import com.artemchep.keyguard.res.Res @@ -21,11 +25,6 @@ import com.artemchep.keyguard.ui.DisabledEmphasisAlpha import com.artemchep.keyguard.ui.theme.combineAlpha import dev.icerock.moko.resources.compose.stringResource -const val URL_JUST_DELETE_ME = "https://justdeleteme.xyz/" -const val URL_HAVE_I_BEEN_PWNED = "https://haveibeenpwned.com/" -const val URL_2FA = "https://2fa.directory/" -const val URL_PASSKEYS = "https://passkeys.directory/" - @Composable fun PoweredByJustDeleteMe( modifier: Modifier = Modifier, diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/totp/formatTotp.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/totp/formatTotp.kt index 44aaaf62..a2af79b4 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/totp/formatTotp.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/totp/formatTotp.kt @@ -3,7 +3,7 @@ package com.artemchep.keyguard.ui.totp import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.buildAnnotatedString import com.artemchep.keyguard.common.model.TotpCode -import com.artemchep.keyguard.ui.asCodePointsSequence +import com.artemchep.keyguard.common.util.asCodePointsSequence import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.toPersistentList diff --git a/common/src/desktopMain/kotlin/com/artemchep/keyguard/copy/DownloadManagerDesktop.kt b/common/src/desktopMain/kotlin/com/artemchep/keyguard/copy/DownloadManagerDesktop.kt index 2b5545d4..f15bcbae 100644 --- a/common/src/desktopMain/kotlin/com/artemchep/keyguard/copy/DownloadManagerDesktop.kt +++ b/common/src/desktopMain/kotlin/com/artemchep/keyguard/copy/DownloadManagerDesktop.kt @@ -10,14 +10,13 @@ import com.artemchep.keyguard.common.service.download.DownloadManager import com.artemchep.keyguard.common.service.download.DownloadProgress import com.artemchep.keyguard.common.service.text.Base64Service import com.artemchep.keyguard.common.usecase.WindowCoroutineScope -import com.artemchep.keyguard.ui.CodeException -import com.artemchep.keyguard.ui.getHttpCode +import com.artemchep.keyguard.common.util.CodeException +import com.artemchep.keyguard.common.util.getHttpCode import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.last