-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: move most of the Preferences activity into a fragment #17487
Conversation
259df21
to
d4c9fd9
Compare
8bb5907
to
f42fa90
Compare
cbb557b
to
c015a66
Compare
c015a66
to
5b0d123
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.
Really solid, thank you!
I don't think any of the comments are blocking
AnkiDroid/src/test/java/com/ichi2/anki/preferences/PreferenceTestUtils.kt
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt
Outdated
Show resolved
Hide resolved
5b0ae77
to
d3c3e62
Compare
@BrayanDSO This is going to conflict with the following, which would be (optionally) nice to get into the 2.19 series Maintainer's choice if we base this PR on top of the above (incurring a slight delay), or defer the above to 2.20 (also acceptable, minor visual bug) |
That bug also happens when clicking a search result, and that PR doesn't fix that. I could fix both issues without much hassle in a commit here. |
d3c3e62
to
631a139
Compare
3099d89
to
3ec71f9
Compare
166cfbd
to
4261190
Compare
4261190
to
f7ba260
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.
LGTM, squash into two commits and merge at will.
Left a minor point about Up if you want to consider it, but I don't consider it blocking.
setTransparentStatusBar() | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
view.findViewById<MaterialToolbar>(R.id.toolbar) | ||
.setNavigationOnClickListener { onBackPressedCallback.handleOnBackPressed() } |
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 haven't flagged this a review request because the previous code has the same behavior, but I think the navigation listener shouldn't behave as the BACK button and it should close the activity:
.setNavigationOnClickListener { requireActivity().finish() }
The Up button should be used to navigate the app screens and not got through all user actions like the BACK button does. It's not something really problematic but I would still go with the platform behavior which the average android user would expect.
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.
Done a change that will lead to the same behavior.
As the toolbar is reused through screens, .setNavigationOnClickListener { requireActivity().finish() }
can't be used without more refactoring.
Since I don't want to wait for a re-review, I'll leave the change to a next PR
f7ba260
to
2649375
Compare
refactor: set fragment tag in SingleFragmentActivity refactor: set back bar in preferences sw600dp layout statically in the XML refactor: set Preferences toolbar title in parent layout Changing the title from child fragments isn't appropriate refactor: simplify getAllCustomButtonKeys refactor: inline HeaderFragment::setDevOptionsVisibility refactor: replace hasLateralNavigation() refactor: move Preferences companion content to top level refactor: replace MINIMUM_CARDS_DUE_FOR_NOTIFICATION with Android resource refactor: replace Preferences::setDevOptionsEnabled removes DevOptionsFragment's dependency on Preferences # Conflicts: # AnkiDroid/src/main/java/com/ichi2/anki/preferences/DevOptionsFragment.kt refactor: inline restartWithNewDeckPicker Used only once. Also, this refactor removes AdvancedSettingsFragment's dependency on Preferences remove Preferences dependency in AboutFragment Using recreate() forces HeaderFragment to be recreated and update the dev options header visibility The snackbar was replaced with a toast because of the recreation. Since dev options is aimed at developers, the UX difference shouldn't matter refactor: inline Preferences::hasAnkiWebAccount used only once
the previous approach only changes the highlight when tapping a HeaderPreference It doesn't listen to backstack changes done by other things, like the back button and the search bar.
I will cut the release-2.20 branch just prior to this merge commit just in case, hopefully no offense @BrayanDSO But! I'm mostly commenting to say that I think we can also flip on the new reviewer by default in a PR as well? line it up for 2.21, get that thing out there |
None taken.
Still a bit far from done. |
Hi there @BrayanDSO! This is the OpenCollective Notice for PRs merged from 2024-12-01 through 2024-12-31 If you are interested in compensation for this work, the process with details is here: https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid Important PLEASE NOTE: The process was updated in August 2024. Re-read the Payment Process page if you have not already. We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding. Thanks! |
Purpose / Description
I want to create a preferences screen for the new reviewer toolbar menu buttons, but the Preferences activity is not flexible enough for what I want to do, so I went on and refactored a good chunk of it to reduce the dependency on
Preferences
and have a bigger fragment modularity.Fixes
Approach
In the commits
How Has This Been Tested?
Emulator 34
uno.webm
developers.developers.developers.webm
tablets.webm
highlight.webm
Checklist
Please, go through these checks before submitting the PR.