0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00
Commit Graph

17537 Commits

Author SHA1 Message Date
David Allison
bf52c41534 add: "Not In LibAnki" annotation 2023-04-25 08:03:48 +03:00
David Allison
fbc82a5698 chore: remove 'MEDIA_CODEC_LIST' from crash reports
I've never used the information, and it makes navigation of the crash log
more difficult than it should be

I'll face the consequences if I'm incorrect here.
2023-04-24 21:56:17 -05:00
David Allison
80106c2e09 chore(DeckDownload): Remove crash report
Getting broadcasts for other downloads is a known case which we handle
, so no need to send a report
2023-04-24 21:38:07 -03:00
David Allison
c2b46f315c fix(DeckDownload): validation stops processing
Previously, getting a broadcast for a download which wasn't ours
would log an error and then attempt to import the file

Fixes 13686
Fixes 13688
2023-04-24 21:38:07 -03:00
David Allison
e614de0312 Revert "Replace MaterialDialog with AlertDialog in SharedDecksDownloadFragment class (#13621)"
This reverts commit 5b0a690790.

Caused the 'YES/NO' buttons to be invisible

Fixes 13690
2023-04-24 21:38:07 -03:00
jDaowy
cc77070631
Fix Warnings in ScopedStorageService.kt (#13642)
* Update ScopedStorageService.kt

Fixed warnings in ScopedStorageService.kt.
issue: #13282

* Removed lines in ScopedStorageService.kt

Deleted the code that was commented out.
2023-04-24 17:21:10 -03:00
David Allison
fc008f0620 build: revert emulator to API 30
API 31 was unstable in CI.

Related: 13695
2023-04-24 16:38:43 +01:00
Mike Hardy
5c9a08b5ea Bumped version to 2.16alpha98 2023-04-23 16:05:50 +00:00
Mike Hardy
1bcf737e97 re-enable play store upload attempts
- will abort (like before) if play store rejects us or play build fails
- will only commit/push build tag if play store works
- universal builds happen after play upload so universal doesn't upload
2023-04-23 10:32:58 -05:00
AnkiDroid Translations
86060f6340 Updated strings from Crowdin 2023-04-23 10:31:29 -05:00
oakkitten
5660104163
Add dialogs for successful & failed storage migration (#13651)
- migration completion notification and dialog
- added showAsyncDialogFragment to show the alert dialog/notification
- added callback in application to get current activity

--- 

* Refactor MigrationSuccessDialogFragment & add MigrationFailedDialogFragment

First of all, this moves MigrationSuccessDialogFragment to
com/ichi2/anki/ui/dialogs/ActivityAgnosticDialogs.kt along with the
related code that tracks the started activities and runs code on start
of any of them.

This also adds MigrationFailedDialogFragment. As we currently lack the
knowledge about what exactly can realistically fail and how, it just
shows the exception text and allows copying the debug info in the same
way as the notification does. It would be nice to try to account for
the most common errors here.

Also this:

  * makes the above dialogs not cancellable on touch outside;

  * adds DefaultActivityLifecycleCallbacks--same as
    Application.ActivityLifecycleCallbacks but with all methods having
    default implementations--for simplicity;

  * adds Activity.canProperlyShowSnackbars() to determine if a
    snackbar, if shown in an activity, will animate properly, or if
    a toast should be shown instead;

  * fixes a slight issue in Snackbars.kt where an activity with a view
    with the ID root_layout would be treated as one that can properly
    show a snackbar--the code wasn't checking whether or not the view
    was CoordinatorLayout so it could produce the wrong result.

* Extract & change strings related to migration success or failure

* Dismiss migration progress dialog when done

* add real URL to storage migration error doc

---------

Co-authored-by: Ashish Yadav <48384865+criticalAY@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
2023-04-23 09:41:53 -05:00
AnkiDroid Translations
6d7b6c8af3 Updated strings from Crowdin 2023-04-23 09:31:00 -05:00
Ashish Yadav
067a5131b0
added a Help button in the notification if the migration fails (#13636) 2023-04-23 09:08:17 -05:00
Arthur Milchior
e5fd5c85c7 NF: refactor close
Slight code simplification while trying to debug why auto-sync causes crash
2023-04-23 11:24:17 +01:00
Prince kushwaha
38f5343b24 Changed Material Dialog with Alert Dialog for CardSideSelectionDialog.kt 2023-04-23 08:35:40 +03:00
David Allison
d133123cea fix: StackOverflowException in androidTest
Cause: `getDefaultAnkiDroidDirectory` caused recursion.
This recursion is normally gated on the existence of PREF_COLLECTION_PATH
But we didn't take this into account when in INSTRUMENTATION_TEST mode

This is fixed incidentally by 6dcf23fd10,
but the underlying cause wasn't handled

Tested by rebasing onto d88ad6251c
and running tests on `playDebug` (API 32 emulator)

Tests now fail due to an alternate setup issue

```
java.lang.NullPointerException
at com.ichi2.anki.TestUtils.isScreenSw600dp(TestUtils.kt:78)
at com.ichi2.anki.DeckPickerTest.checkIfStudyOptionsIsDisplayedOnTablet(DeckPickerTest.kt:91)
```

Fixes 13644
2023-04-23 06:52:10 +02:00
David Allison
c0d004b511 chore: fix typo [MigrateEssentialFiles] 2023-04-23 07:14:38 +03:00
David Allison
79db94aafd fixup: MigrationService: Progress is incorrect after service restart
13658 was accidentally merged with pending review comments

Related: 13658 (fixups for this PC)
Related: 13634
2023-04-22 12:13:22 -03:00
David Allison
6dcf23fd10 fix: Ensure 'MANAGE_EXTERNAL_STORAGE' is requested if needed
Scenario:
* The user can request 'MANAGE_EXTERNAL_STORAGE' (non-Play build)
* The collection path is `/storage/emulated/0/AnkiDroid`
* The user is on API 30
* The user reinstalled & kept data

Expected Result:
* We require 'MANAGE_EXTERNAL_STORAGE' to continue to access data

Previously:
1. We requested READ/WRITE_EXTERNAL_STORAGE
2. When accepted: 'StorageAccessException': User no longer had access
  to legacy storage.

Implementation:
This splits `hasLegacyStoragePermissions` into two concepts:

1. Do we have a legacy collection
2. Does Android allow us to use legacy folders

Previously we only checked for (1) whereas we needed both
2023-04-22 12:10:34 -03:00
David Allison
d88ad6251c refactor: extract 'selectAnkiDroidFolder'
Second parameter was always the same, we're going to add another
default and want to abstract this out to clean up the diff
2023-04-22 12:10:34 -03:00
Ashutosh Kumar Kushwaha
5b0a690790
Replace MaterialDialog with AlertDialog in SharedDecksDownloadFragment class (#13621)
* Replace MaterialDialog with AlertDialog in SharedDecksDownloadFragment.kt

* Replace AlertDialog.Builder with
MaterialAlertDialogBuilder in SharedDecksDownloadFragment.kt

* Remove Suppress onBackPressed deprecation
in SharedDecksDownloadFragment.kt

* Add Suppress onBackPressed deprecation
in SharedDecksDownloadFragment.kt

* Replace MaterialAlertDialogBuilder
with AlertDialog.Builder in SharedDecksDownloadFragment.kt

* Replace MaterialAlertDialogBuilder
with AlertDialog.Builder in SharedDecksDownloadFragment.kt

* Revert "Replace MaterialAlertDialogBuilder"

This reverts commit b0d358cb6c.

* Remove .create()
in showCancelConfirmationDialog()
in SharedDecksDownloadFragment.kt
2023-04-22 15:13:33 +01:00
github-actions[bot]
d4ed63682c
Update Gradle Wrapper from 8.0.2 to 8.1.1. (#13653) 2023-04-22 07:29:33 -05:00
David Allison
567f131dfd refactor: convert getOrSetString to extension method
Kotlin Cleanup
2023-04-22 07:27:07 -05:00
David Allison
e1ef7743de fix: MigrationService: Progress is incorrect after service restart
* Save a variable to Shared Preferences
* Restore & use it while converting

Fixes 13634
2023-04-22 07:27:07 -05:00
David Allison
1ff9c9d8bf fix: collectionWillBeMadeInaccessibleAfterUninstall
Boolean was reversed. Spec was:
return `false` if "The collection is now inaccessible"
2023-04-22 07:01:24 -05:00
David Allison
a419ea3cc7 fix: migrationStatus - IN_PROGRESS has priority
this was previously a permissions check, which should
have had priority. Now we no longer request permissions,
this check should have been moved down, and not added to
2023-04-22 07:01:24 -05:00
gradle-update-robot
c6bf4f3b00 Update Gradle Wrapper from 8.0.2 to 8.1.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2023-04-22 06:54:44 -05:00
snowtimeglass
a24217b1f8 Use another icon for suggesting backup if no sync
(Use an alternate design for the icon of the backup suggestion dialog box
if the user doesn't use the sync feature)

The current icon with an upward arrow in a cloud alludes uploading data to cloud (AnkiWeb).
Its design is misleading for encouraging backup to those who don't use the sync feature.

By this commit, an icon which generally means "Setting backup restore" will be shown
instead of the current icon when the user hasn't logged in to their AnkiWeb account.
2023-04-22 06:49:23 -03:00
Prince kushwaha
83fb72bfde Changed Material Dialog with Alert Dialog for ReadText.kt 2023-04-22 11:25:02 +03:00
Sanjaykumar Sargam
d7fd38fded Implemented cancel button in add note type dialog 2023-04-22 10:35:56 +03:00
Mike Hardy
a86277fdee
Dependency updates 20230421 (#13650)
* build(deps): bump androidx.activity:activity-ktx from 1.7.0 to 1.7.1

Bumps androidx.activity:activity-ktx from 1.7.0 to 1.7.1.

---
updated-dependencies:
- dependency-name: androidx.activity:activity-ktx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump fragments_version from 1.5.6 to 1.5.7

Bumps `fragments_version` from 1.5.6 to 1.5.7.

Updates `androidx.fragment:fragment-ktx` from 1.5.6 to 1.5.7

Updates `androidx.fragment:fragment-testing` from 1.5.6 to 1.5.7

---
updated-dependencies:
- dependency-name: androidx.fragment:fragment-ktx
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: androidx.fragment:fragment-testing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump com.google.protobuf:protobuf-kotlin

Bumps com.google.protobuf:protobuf-kotlin from 3.22.2 to 3.22.3.

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-kotlin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump lint_version from 30.4.2 to 31.0.0

Bumps `lint_version` from 30.4.2 to 31.0.0.

Updates `com.android.tools.lint:lint-api` from 30.4.2 to 31.0.0

Updates `com.android.tools.lint:lint` from 30.4.2 to 31.0.0

Updates `com.android.tools.lint:lint-tests` from 30.4.2 to 31.0.0

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump io.mockk:mockk from 1.13.4 to 1.13.5

Bumps [io.mockk:mockk](https://github.com/mockk/mockk) from 1.13.4 to 1.13.5.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/commits)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-21 17:49:36 -05:00
Arthur Milchior
411f9ad5c8 if destination is a prefix of source, delete destination
As I found the code quite confusing to read, I rewrote it to split in three cases:
* source does not exists
* destination exists
* move can occur as expected

Only change: if a move from a non-existing file to an existing file is
requested, report progress 0. After all, 0 bytes were copied, but one
instruction was executed.

Fixed: #13170
2023-04-21 17:29:49 -05:00
Arthur Milchior
a5e933771d NF: introduce FilePrefix and isPrefix 2023-04-21 17:29:49 -05:00
David Allison
9fdfbe0b12 fix: storage migration shown on API 27
We were using the condition `allFileAccessPermissionGranted`

But this returns false before API 30

Instead define and use `collectionWillBeMadeInaccessibleAfterUninstall`
which takes this condition into account

Fixes 13612
2023-04-21 16:16:02 -05:00
David Allison
04717c4d96 docs: collectionWasMadeInaccessibleAfterUninstall 2023-04-21 16:16:02 -05:00
AnkiDroid Translations
180dae6a0f Updated strings from Crowdin 2023-04-21 15:12:28 -05:00
Chandra Mauli Sharma
48ee19fb8c
Find Key Shortcut for Card Browser (#13635)
* Find Key Shortcut for Card Browser

* Lint fix at line 773
2023-04-21 18:13:21 +03:00
David Allison
b4c5baf3f0 build: update targetSdkVersion to 31 2023-04-21 17:22:28 +03:00
Brayan Oliveira
ce0b0dc9ff
Fix "Access denied" errors after upgrading from 2.15.6 (#13630)
* Fix "Access denied" errors after upgrading from 2.15.6

selectAnkiDroidFolder() didn't handle the case of the user keeping the legacy storage permissions on an Android 11+ device

* fixup! Fix "Access denied" errors after upgrading from 2.15.6

* NF: Use named argument
2023-04-20 16:15:43 +03:00
oakkitten
98e189d849 Add TODO regarding a wake-lock in MigrationService 2023-04-19 10:03:42 +01:00
oakkitten
6da2809b1f Edit TODO regarding migration-related preferences
This might be a race condition or it might be a non-issue.
This is not blocking the merge and might take a long time to resolve.
2023-04-19 10:03:42 +01:00
oakkitten
d901ec0957 Resolve TODO in MigrationService.onCreate
This moves the creation of MigrateUserData to a background thread.
Note that this does move the creation of an instance of
UserDataMigrationPreferences to the background thread as well.
2023-04-19 10:03:42 +01:00
oakkitten
5f3a935d9c Resolve TODOs regarding instantiation of MigrateUserData
This moves the creation of MigrateUserData to a background thread.
Note that this does move the creation of an instance of
UserDataMigrationPreferences to the background thread as well.
2023-04-19 10:03:42 +01:00
oakkitten
eb765d4ed7 Remove TODO regarding MigrationService throwing MigrateUserData.MissingDirectoryException
Now tracked via the 2.16 & Scoped Storage project

See conversation at:
https://github.com/ankidroid/Anki-Android/pull/13368#discussion_r1161314362
2023-04-19 10:03:42 +01:00
oakkitten
7134cca7bf Mark TODOs as to be looked at BEFORE-MERGE or BEFORE-RELEASE
As requested. Terminology:

* TODO BEFORE-MERGE means that the TODO SHOULD be resolved before the
  commit is merged into main;

* TODO BEFORE-RELEASE means that the TODO SHOULD be resolved before the
  release of the new stable version;

* If the tag is followed by an exclamation mark, e.g.
  TODO BEFORE-MERGE!, replace SHOULD with MUST, as per RFC 2119.
2023-04-19 10:03:42 +01:00
oakkitten
c9562999ed Use CircularProgressIndicator in MigrationProgressDialogFragment 2023-04-19 10:03:42 +01:00
oakkitten
d7821f9ef3 Use CircularProgressIndicator in DeckPicker toolbar 2023-04-19 10:03:42 +01:00
oakkitten
70522145de Use StateFlow for publishing migration progress
Splitting this into several commits would be too hard, so sorry about
this commit doing a lot of things at once.

* Migration service is refactored in a major way. For progress,
  StateFlow is used. Progress now includes not only the transfer stage,
  but also the stage of calculating transfer size and success/failure
  states. UI reads this progress directly.

* Binding to the service is performed using coroutines, which should
  simplify integrating services with UI.

* The ongoing-migration toolbar button in DeckPicker now starts at 5% so
  that the user sees at least some of the circular progress indicator in
  the very beginning.
2023-04-19 10:03:42 +01:00
Ashish Yadav
aa3675d465 removed percentage and updated the string 2023-04-19 10:03:42 +01:00
Ashish Yadav
e6901eec37 added migration progress bar and simplfied code 2023-04-19 10:03:42 +01:00