-
-
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
Sync from reviewer when we didn't want through the deck picker #17399
base: main
Are you sure you want to change the base?
Conversation
835a76e
to
b2e9176
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.
I don't know the code of Reviewer2/ReviewerFragment. So this is only
enabled in the legacy reviewer. I hope the code is simple enough for
the feature to be easily ported to the other reviewers now that the
entire sync part of the code was decoupled from the DeckPicker.
From an architecture perspective, supporting the new reviewer is the most important thing to get right. We want to move to the new reviewer (which affects everyone; this change only affects a subset of users), and if this PR doesn't support the new reviewer, then we're adding more friction to switching to the reviewer
I've reviewed the first two commits and they both look great. I'd strongly support a new PR to split them out if the rework of this PR will take some time.
Done in #17417 I admit I don't know the new reviewer at all. I didn't even know a new reviewer was considered. I'll take a look |
It's in the developer options, it looks great and I feel we all strongly want to make it the default |
so I tried. |
Rebased on top of #17422 so that the deck picker widget can use the new reviewer. |
b2e9176
to
9412182
Compare
Feature is now ported to the new reviewer. |
Conflicts |
9412182
to
f0a5b4f
Compare
Conflict resolved |
f0a5b4f
to
55c351d
Compare
55c351d
to
f3f5180
Compare
9d96fc9
to
8b053c3
Compare
b44f7d5
to
34a5e97
Compare
34a5e97
to
a1b7b11
Compare
minor lint issue |
/** | ||
* Class in charge of doing the sync work for another activity. | ||
*/ | ||
class SyncHandler( |
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.
Sync.kt
is already pretty big isn't it? Could this reasonably go in its own file?
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.
Excited to see this go in, looks like there was a lot of progress on the build-up refactors etc and most of those will likely be in today or tomorrow with a bit more back and forth. This one maybe tomorrow or next day depending on time available
I tried
would you have any idea why it success locally and not on github? |
a1b7b11
to
e85d76e
Compare
no idea but looks like it resolved :-) |
18c7462
to
be10887
Compare
Currently it's only an extra indirection layer, as all provider are returning themselves. In the next commit, it'll be used to ensure that the activity don't have to implements the listener itself.
This class deals with the entire Sync part of the deck picker.
The enum was used only in one function. Adding an intermediary step does not add clarity to the code. Each method were also only used once. I think the resulting code is easier to read, thanks to less layer of abstractions.
Widgets and shortcuts allows to directly review a deck. This means that automated sync, or even manual sync, is never available. Except if the user close the reviewer and then manually open ankidroid. This create a lot of friction on a very important feature. This commit enable the sync feature in the reviewer, but hides it unless the intent actually requested it. In my opinion, it should be always available. It's available in anki upstream from the reviewer, and anki allows automated save every 10 minutes. Which means even if your device suddenly dies during a streak, you only lose up to 10 minutes of review. Still, this feature at least improve the case that was the most dangerous for users (and frustrating for me) I don't know the code of Reviewer2/ReviewerFragment. So this is only enabled in the legacy reviewer. I hope the code is simple enough for the feature to be easily ported to the other reviewers now that the entire sync part of the code was decoupled from the DeckPicker. Manually tested with: * signin in (when no account present) * full sync (requested locally and requested by ankiweb) * normal sync * changing the selected deck on the other device To test it you should use a widget or a shortcut. One point amy need to be changed. The little icon that state that there is a not-uploaded change. While it's okay in the deckpicker, it may not be ideal to have it as soon as we have the first review done.
be10887
to
fcd137c
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.
Fundamentally: I don't feel we should have a UI to sync from the reviewer.
I wouldn't mind it via the JS API, or being performed automatically on open/close, but not as a UI option. It turns the Reviewer into a "do everything" screen
@@ -33,7 +33,11 @@ import com.ichi2.anki.showError | |||
import com.ichi2.anki.utils.ext.dismissAllDialogFragments | |||
|
|||
class SyncErrorDialog : AsyncDialogFragment() { | |||
interface SyncErrorDialogListener { | |||
interface SyncErrorDialogListenerProvider { |
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.
Can we remove this and use a delegation?
throw exc | ||
} | ||
updateLogin(baseContext, username, auth.hkey) | ||
setResult(RESULT_OK) |
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 looks incorrect: the activity doesn't wait for the task to complete
* this program. If not, see <http://www.gnu.org/licenses/>. * | ||
****************************************************************************************/ | ||
|
||
package com.ichi2.anki |
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.
can we move this into a subpackage?
/** | ||
* Class in charge of doing the sync work for another activity. | ||
*/ | ||
class SyncHandler( |
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 far too coupled to implementation details for it to be worthwhile. the UI code shouldn't be here
@@ -153,6 +154,9 @@ class IntentHandler : AbstractIntentHandler() { | |||
} else { | |||
Intent(this, Reviewer::class.java) | |||
} | |||
if (intent.extras?.getBoolean(ENABLE_SYNC) == true) { |
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.
Should this be handled by the reviewer at all if there's no UI updates? Can we do it when we receive an intent instead?
@@ -206,6 +224,12 @@ open class Reviewer : | |||
|
|||
private val flagItemIds = mutableSetOf<Int>() | |||
|
|||
// flag keeping track of when the app has been paused | |||
var activityPaused = false |
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 should be using lifecycle aware components, or querying the lifecycle manually
@@ -409,6 +445,18 @@ open class Reviewer : | |||
Timber.i("Reviewer:: Home button pressed") | |||
closeReviewer(RESULT_OK) | |||
} | |||
R.id.action_sync -> { |
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 don't think this belongs here. If a user wants to sync from a widget, they can turn on auto-sync and have it handled by the code you're adding
Sync enabled in the reviewer when the deck picker was not used
Widgets and shortcuts allows to directly review a deck.
This means that automated sync, or even manual sync, is never
available. Except if the user close the reviewer and then manually
open ankidroid. This create a lot of friction on a very important
feature.
This commit enable the sync feature in the reviewer, but hides it
unless the intent actually requested it.
In my opinion, it should be always available. It's available in anki
upstream from the reviewer, and anki allows automated save every 10
minutes. Which means even if your device suddenly dies during a
streak, you only lose up to 10 minutes of review.
Still, this feature at least improve the case that was the most
dangerous for users (and frustrating for me)
I don't know the code of Reviewer2/ReviewerFragment. So this is only
enabled in the legacy reviewer. I hope the code is simple enough for
the feature to be easily ported to the other reviewers now that the
entire sync part of the code was decoupled from the DeckPicker.
Manually tested with:
To test it you should use a widget or a shortcut.
One point amy need to be changed. The little icon that state that
there is a not-uploaded change. While it's okay in the deckpicker, it
may not be ideal to have it as soon as we have the first review done.