-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update copy when deleting passwords to consider whether sync enabled …
…or not (#4445) Task/Issue URL: https://app.asana.com/0/488551667048375/1206638124888258/f ### Description Copy changes around deleting passwords (now showing a different message when sync is enabled vs disabled). Translations will come in #4446 # Steps to test this PR ## Sync Disabled ### single saved password - [ ] Disable sync (or leave it disabled if off already) - [ ] Visit password management screen (overflow -> passwords) - [ ] Add a single saved password (so you only have 1 total). - [ ] Return to password management screen - [ ] Then choose overflow -> Delete All Passwords - [ ] Verify the dialog title is **Are you sure you want to delete this password?** - [ ] Verify the dialog message says "password" (singular) and "account" (singular) - [ ] Verify the dialog message says it'll be "deleted from this device" - [ ] Cancel the prompt. Click on the overflow of the saved password, and choose **Delete**. Ensure the last two checks you just did are still valid for this scenario. ### multiple saved passwords - [ ] Add a second saved password (so you now have 2 total), and return to password management screen - [ ] Then choose overflow -> Delete All Passwords - [ ] Verify the dialog title is **Are you sure you want to delete 2 passwords** - [ ] Verify the dialog message says "password**s**" and "account**s**" - [ ] Verify the dialog message says it'll be "deleted from this device" ## Sync Enabled ### multiple saved passwords - [ ] Enable sync - [ ] Visit password management screen (overflow -> passwords). Ensure you have > 1 saved password. - [ ] Then choose overflow -> Delete All Passwords - [ ] Verify the dialog title is **Are you sure you want to delete 2 passwords** - [ ] Verify the dialog message says "password**s**" and "account**s**" - [ ] Verify the dialog message says it'll be "deleted from all synced devices" ### single saved password - [ ] Enable sync - [ ] Visit password management screen (overflow -> passwords). Ensure you have exactly 1 saved password. - [ ] Then choose overflow -> Delete All Passwords - [ ] Verify the dialog title is **Are you sure you want to delete this password?** - [ ] Verify the dialog message says "password" (singular) and "account" (singular) - [ ] Verify the dialog message says it'll be "deleted from all synced devices"
- Loading branch information
Showing
30 changed files
with
259 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...kduckgo/autofill/impl/ui/credential/management/viewing/AutofillManagementStringBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2024 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.autofill.impl.ui.credential.management.viewing | ||
|
||
import android.content.Context | ||
import android.content.res.Resources | ||
import com.duckduckgo.autofill.impl.R | ||
import com.duckduckgo.common.utils.DispatcherProvider | ||
import com.duckduckgo.di.scopes.FragmentScope | ||
import com.duckduckgo.sync.api.DeviceSyncState | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.withContext | ||
|
||
interface AutofillManagementStringBuilder { | ||
fun stringForDeletePasswordDialogConfirmationTitle(numberToDelete: Int): String | ||
suspend fun stringForDeletePasswordDialogConfirmationMessage(numberToDelete: Int): String | ||
} | ||
|
||
@ContributesBinding(FragmentScope::class) | ||
class AutofillManagementStringBuilderImpl @Inject constructor( | ||
private val context: Context, | ||
private val deviceSyncState: DeviceSyncState, | ||
private val dispatchers: DispatcherProvider, | ||
) : AutofillManagementStringBuilder { | ||
|
||
override fun stringForDeletePasswordDialogConfirmationTitle(numberToDelete: Int): String { | ||
if (numberToDelete == 1) { | ||
return context.getString(R.string.credentialManagementDeleteAllPasswordsDialogConfirmationTitleSingular) | ||
} | ||
|
||
return context.resources.getQuantityString( | ||
R.plurals.credentialManagementDeleteAllPasswordsDialogConfirmationTitlePlural, | ||
numberToDelete, | ||
numberToDelete, | ||
) | ||
} | ||
|
||
override suspend fun stringForDeletePasswordDialogConfirmationMessage(numberToDelete: Int): String { | ||
val firstMessage = context.resources.deleteAllPasswordsWarning(numberToDelete) | ||
val secondMessage = if (numberToDelete == 1) { | ||
context.resources.getString(R.string.credentialManagementDeleteAllSecondInstructionSingular) | ||
} else { | ||
context.resources.getQuantityString(R.plurals.credentialManagementDeleteAllSecondInstructionPlural, numberToDelete) | ||
} | ||
return "$firstMessage $secondMessage" | ||
} | ||
|
||
private suspend fun Resources.deleteAllPasswordsWarning(numberToDelete: Int): String { | ||
return withContext(dispatchers.io()) { | ||
return@withContext if (deviceSyncState.isUserSignedInOnDevice()) { | ||
if (numberToDelete == 1) { | ||
getString(R.string.credentialManagementDeleteAllPasswordsFirstInstructionSyncedSingular) | ||
} else { | ||
getQuantityString(R.plurals.credentialManagementDeleteAllPasswordsFirstInstructionSyncedPlural, numberToDelete) | ||
} | ||
} else { | ||
if (numberToDelete == 1) { | ||
getString(R.string.credentialManagementDeleteAllPasswordsDialogFirstInstructionNotSyncedSingular) | ||
} else { | ||
getQuantityString(R.plurals.credentialManagementDeleteAllPasswordsDialogFirstInstructionNotSyncedPlural, numberToDelete) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.