For #10173: login duplicates and save #11208
For #10173: login duplicates and save #11208
Conversation
16dcf0b
to
2e84b3c
Compare
app/src/main/java/org/mozilla/fenix/settings/logins/EditLoginFragment.kt
Outdated
Show resolved
Hide resolved
843a584
to
60cca68
Compare
This comment has been minimized.
This comment has been minimized.
Can you comment the filed out data review form here so we can get that review rolling too? see example: #11446 (comment) |
Request for data collection review formAll questions are mandatory. You must receive review from a data steward peer on your responses to these questions before shipping new data collection.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, all the pieces look there but we need to refactor some of the architecture. Let's not create a new paradigm here if possible! The interactor -> controller model that is used elsewhere should really replace the LoginsDataStore
. Look at bookmarks, history, or the other logins fragments for examples of how this should look. You should start with a View
for the EditLoginFragment
following the pattern of the other fragments, then we can update that view in consumeFrom
. The view can call the interactor, and the interactor calls the controller.
Let's pull out the string to land separately so we can definitely make string freeze by tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data-review+ only
A few nits and renaming, inline
Data Review Form (to be filled by Data Stewards)
- Is there or will there be documentation that describes the schema for the ultimate data set in a public, complete, and accurate way?
Yes, documented the 3 view/edit/delete password probes added
- Is there a control mechanism that allows the user to turn the data collection on and off?
Yes, controlled by Fenix data controls
- If the request is for permanent data collection, is there someone who will monitor the data over time?
Probes have expiry
- Using the category system of data types on the Mozilla wiki, what collection type of data do the requested measurements fall under?
Type 2, interaction with settings
- Is the data collection request for default-on or default-off?
default on
- Does the instrumentation include the addition of any new identifiers (whether anonymous or otherwise; e.g., username, random IDs, etc. See the appendix for more details)?
No, user interaction with UI
- Is the data collection covered by the existing Firefox privacy notice?
Yes
- Does there need to be a check-in in the future to determine whether to renew the data? (Yes/No) (If yes, set a todo reminder or file a bug if appropriate)**
No
- Does the data collection use a third-party collection tool?
no
60cca68
to
9834eb1
Compare
app/src/main/java/org/mozilla/fenix/settings/logins/LoginsDataStore.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/EditLoginFragment.kt
Show resolved
Hide resolved
66c95e0
to
461428e
Compare
05f794a
to
0afbeec
Compare
Waiting on mozilla/application-services#3331 to land |
b4c25cb
to
13b45a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much better! Wondering if we can do some of the cleanup I suggested and if you could also cherry-pick @Mugurell 's commits from #12507 into this PR? (Since they conflict with some of your changes)
cc @Mugurell if you also wanted to take a look at these logins changes and leave some feedback since you've been touching it more recently
getString( | ||
R.string.history_delete_single_item_snackbar, | ||
historyItems.first().url.toShortUrl(requireComponents.publicSuffixList) | ||
String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint/detekt error
app/src/main/java/org/mozilla/fenix/settings/logins/LoginsFragmentStore.kt
Show resolved
Hide resolved
private val navController: NavController, | ||
private val loginsFragmentStore: LoginsFragmentStore | ||
) { | ||
private val activity: HomeActivity = context as HomeActivity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - if we're only using the context to grab the activity can we just pass in the activity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also looking at the rest of the class it's unclear to me why we need to cast this context to an activity? Can we just use the passed in context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the Context..
I'm normally against passing it around and then expect all receivers to know how to build/extract their end dependencies from it. (Demeter's law).
To keep the code clean, have a better separation of responsibilities, loose coupling and ease testing I would propose to have end dependencies sent as parameters to the controller.
Here I see that anyway the context, cast to a specific activity!? is only used for obtaining a reference to components.core.passwordsStorage
. That can easily be injected in the constructor without even worrying about it become bloated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a flow taken from a number of other places in the app. I would not like to change it without cleaning up every other place as well. Maybe we can file an eng health ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fenix/app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt
Line 19 in f424656
private val context: Context, |
fenix/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkController.kt
Line 52 in f424656
private val activity: HomeActivity, |
fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt
Line 63 in f424656
private val activity: HomeActivity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a common pattern in the rest of the app (that we can file a followup ticket about), but in this case we really are only using the context to get the passwordsStorage
, so instead of passing in the context, we can just pass in the passwordsStorage
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to use context instead of HomeActivity, and filed a followup: #12565
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can still improve this further by changing it pass passwordsStorage
directly since AFAICT that's all we use it for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it cool to pass a component around like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/src/main/java/org/mozilla/fenix/settings/logins/interactor/SavedLoginsInteractor.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/EditLoginView.kt
Outdated
Show resolved
Hide resolved
containerView.passwordText?.inputType = | ||
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD | ||
containerView.revealPasswordButton?.setImageDrawable( | ||
ResourcesCompat.getDrawable(context.resources, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elsewhere we use AppCompatResources.getDrawable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a lint or detekt error telling me to use ResourcesCompat. I can use AppCompatResources instead :)
app/src/main/java/org/mozilla/fenix/settings/logins/view/EditLoginView.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/LoginDetailView.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some drop-by comments mainly about the architecture.
If we are to refactor this I think we should also focus on improving the architecture and code quality.
@@ -54,11 +54,11 @@ sealed class LoginsAction : Action { | |||
data class UpdateLoginsList(val list: List<SavedLogin>) : LoginsAction() | |||
data class UpdateCurrentLogin(val item: SavedLogin) : LoginsAction() | |||
data class SortLogins(val sortingStrategy: SortingStrategy) : LoginsAction() | |||
data class ListOfDupes(val dupeList: List<SavedLogin>) : LoginsAction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/mozilla-mobile/fenix/blob/master/docs/architecture-overview.md#action
"An Action describes something that happened, and carries any data relevant to that change"
Maybe this Action can be changed to something like "DuplicatesListChanged"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this name. If possible duplicates exist, this list is non-empty. The action does not depend on the list changing; it will be changing with every edit.
private val navController: NavController, | ||
private val loginsFragmentStore: LoginsFragmentStore | ||
) { | ||
private val activity: HomeActivity = context as HomeActivity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the Context..
I'm normally against passing it around and then expect all receivers to know how to build/extract their end dependencies from it. (Demeter's law).
To keep the code clean, have a better separation of responsibilities, loose coupling and ease testing I would propose to have end dependencies sent as parameters to the controller.
Here I see that anyway the context, cast to a specific activity!? is only used for obtaining a reference to components.core.passwordsStorage
. That can easily be injected in the constructor without even worrying about it become bloated.
|
||
interactor = LoginDetailInteractor( | ||
SavedLoginsStorageController( | ||
context = requireContext(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should look into passing end dependencies to clients and so remove the responsability of them knowing how to and creating such dependencies.
In this case the context seems to only be used for getting components.core.passwordsStorage
. We can pass that instead of the Context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this might warrant a larger cleanup in the codebase...
app/src/main/java/org/mozilla/fenix/settings/logins/fragment/LoginDetailFragment.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/LoginDetailView.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/interactor/SavedLoginsInteractor.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/interactor/SavedLoginsInteractor.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/EditLoginView.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/LoginDetailView.kt
Show resolved
Hide resolved
app/src/main/java/org/mozilla/fenix/settings/logins/view/LoginDetailView.kt
Show resolved
Hide resolved
One other important improvement to be made: |
997d70a
to
453b7b3
Compare
Addressed comments. Will rebase with Mugurell's PR once it's merged. Once the app services version (62.0.0) is updated in AC and we get that version into Fenix, I would like this to land and then do followups. I don't want to keep this open for any longer than it already has been.
453b7b3
to
b0ae597
Compare
test-debug failing on |
…er based on username. Create edit login controller. Add text watchers and check for duplicates. Edit controller test
Move duplicates logic into the controller
…n into the datastore.
Save enabled in datastore. Move login data to datastore Rebase with password error states Update metrics to be more specific for edit
…parate out some layout manipulation. Inflate view in edit fragment. Double layout showing up. Edit view Controller tests Controller tests passing Interactor tests Lint and detekt cleanup
a35683a
to
68895cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+ with ktlint fix up :)
…assword storage. Addressed comments Lint : Rebase - 1
68895cb
to
9b78c12
Compare
For #10173
Related to mozilla/application-services#3330 - fix in mozilla/application-services#3331
Requires mozilla-mobile/android-components#7694
Requirements for this PR
components.core.passwordsStorage
calls into their own store:LoginsDataStore
Pull Request checklist
After merge
To download an APK when reviewing a PR: