Skip to content
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

Show toast when importing without the app being started at least once #15692

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

lukstbit
Copy link
Member

Purpose / Description

Fixes the linked issues by notifying the user through a toast(suggestions for the notice message of course welcome) and aborting the import that he must start the app at least once before he can import. At first I tried to be more precise in DeckPicker to try to remove the import dialog message from the handler and then show the toast, this didn't worked at all so I moved the check in IntentHandler.

Fixes

How Has This Been Tested?

Ran the tests(but hit some OutOfMemoryErrors) and manually installed debug apks(play and full) to first reproduce and then check the patch.

Learning (optional, can help others)

I dislike the handler system used for async dialogs.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Contributor

Message to maintainers, this PR contains strings changes.

  1. Before merging this PR, it is best to run the "Sync Translations" GitHub action, then make and merge a PR from the i18n_sync branch to get translations cleaned out.
  2. Then merge this PR, and immediately do another translation PR so the huge change made by this PR's key changes are all by themselves.

Read more about updating strings on the wiki,

@@ -351,6 +351,9 @@
<string name="intro_get_started" comment="Action to start AnkiDroid for the first time without syncing from AnkiWeb">Get Started</string>
<string name="intro_sync_from_ankiweb">Sync from AnkiWeb</string>

<!-- IntentHandler -->
<string name="warning_start_app_before_import">Before importing app must be opened at least once for initialization</string>
Copy link
Member

@david-allison david-allison Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels verbose:

"Please open Anki and try again"? Or similar

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good to me as a way to handle the problem
I tried to take the strings suggestion to a prescriptive recommendation for an up/down vote so we can get this in quickly I hope

My approval is pending commit on those string proposals which I can do then squash-merge or can be done via rebase and pushed via lukstbit, either would work for me

If more discussion is needed because you all hate my suggestions (fair enough!) then I'll re-look after

AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt Outdated Show resolved Hide resolved
@@ -351,6 +351,9 @@
<string name="intro_get_started" comment="Action to start AnkiDroid for the first time without syncing from AnkiWeb">Get Started</string>
<string name="intro_sync_from_ankiweb">Sync from AnkiWeb</string>

<!-- IntentHandler -->
<string name="warning_start_app_before_import">Before importing app must be opened at least once for initialization</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the new string name from first comment, then I prefer a "what" message for users, followed by "prescriptive action". So I'd say:

Suggested change
<string name="warning_start_app_before_import">Before importing app must be opened at least once for initialization</string>
<string name="app_not_initialized">AnkiDroid is not initialized yet. Please open AnkiDroid once, then try again</string>

@david-allison would this work for you? If so and you're +1 on the rest of it, commit+squash these myself to get this in and queue up a 2.17.2 or obviously @lukstbit can (and also, obviously, if either of you disagree on my string-crafting let me know please!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with your suggestion, David's suggestion might sound a bit negative to the user(like some unknown error happened).

@mikehardy mikehardy added Review High Priority Request for high priority review Needs Second Approval Has one approval, one more approval to merge Queued for Cherry Pick to Stable Branch labels Feb 28, 2024
@mikehardy mikehardy added this to the 2.17.2 release milestone Feb 28, 2024
The current implementation using messages and handlers for async dialogs
means that if the user tries to import before actually starting the app
the import dialog ends up being shown in the introduction screen ending
up in a crash. These changes prevent that by checking for this scenario
and notifying the user that he must start the app at least once before
any import can be done.

The hasShownAppIntro() was moved to better structure the code(it's related
to the introduction screen) and for ease of access in the screens that use it.
Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously works for me then since you just accepted all my changes 😆 - approving for avoidance of doubt, pending David saying yay/nay

@david-allison
Copy link
Member

I feel it's a little verbose still, but two votes to one 😁

Let's get this in

@david-allison david-allison added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Feb 28, 2024
@david-allison
Copy link
Member

@lukstbit lukstbit added this pull request to the merge queue Feb 28, 2024
@mikehardy
Copy link
Member

Note to myself more than anything - needs a string sync afterwards, and that strings sync needs a queued for cherry-pick label

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 28, 2024
@mikehardy mikehardy added this pull request to the merge queue Feb 28, 2024
@mikehardy
Copy link
Member

We have a new flaky test after the intent handling changes, this popped up on another PR recently as well and caused merge queue ejection


com.ichi2.anki.NoteEditorIntentTest > launchActivityWithIntent[emulator-5554 - 11] FAILED 
	java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
	at com.ichi2.anki.NoteEditorIntentTest.launchActivityWithIntent$lambda$0(NoteEditorIntentTest.kt:54)

Merged via the queue into ankidroid:main with commit 4717ba6 Feb 28, 2024
7 checks passed
@github-actions github-actions bot modified the milestones: 2.17.2 release, 2.18 release Feb 28, 2024
@github-actions github-actions bot removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) Review High Priority Request for high priority review labels Feb 28, 2024
@lukstbit lukstbit deleted the fix_importBeforeAppStart branch February 29, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] 2.17.1 IntroductionActivity cannot be cast to DeckPicker
3 participants