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

17473 Commits

Author SHA1 Message Date
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
Ashish Yadav
7e2248d587 added migration progess bar using fragment dialog 2023-04-19 10:03:42 +01:00
Ashish Yadav
b5e9992317 custom study deck settings error handling 2023-04-19 07:56:26 +03:00
lukstbit
63cc2ae3be Fix views placement issues for introduction layout
This PR mainly fixes issues with the app logo in landscape when on screens with bigger sizes and also changes how the
gradient works to better cover the screen in landscape.
2023-04-16 10:07:39 -03:00
lukstbit
e2f816d923 Fix message string for AlertDialog in IntroductionActivity
The string R.string.ankidroid_init_failed_webview is a string resource which uses a placeholder value which was not registered
 corectly in IntroductionActivity.
2023-04-16 10:07:39 -03:00
Mike Hardy
95eac24022 revert jacoco from 0.8.9 to 0.8.8 - macOS runner cannot find it
has caused spurious errors from other runners as well and from
individual contributors. Feels like the global maven central CDN
is not in sync but that is also not in our control, so revert
2023-04-16 00:18:38 +01:00
Arthur Milchior
613f6597c8 ensure scripts prints escaped character
On my desktop, running `./tools/storage/set_scopde_storage.sh` led to

> Alienware% ./tools/storage/set_scoped_storage.sh
> First argument missing.
> \nPossible arguments:
> limited\t\tEquivalent to a fresh install. /AnkiDroid/ is inaccessible
> full\t\tEquivalent to an upgrade from targetSdkVersion 29 to 30. /AnkiDroid/ is accessible\n

Adding `-e` ensures the characters are printed as expected.
2023-04-15 14:38:14 -03:00
Arthur Milchior
6ce32a5a50 Use shebang in set_scoped_storage
Otherwise, bash is not used. Instead, I get
> ./tools/storage/set_scoped_storage.sh: 5: Syntax error: "(" unexpected

because `function` is not basic shell I guess.
2023-04-15 14:37:22 -03:00
Pratyaksh Khurana
7c8bcbe299
fix: Changed title and action names of cancel share deck download dialog (#13587)
* changed title and action names of cancel share deck download dialog

* updated cancel_download_question_title string

* revert cancel download title
2023-04-15 11:29:42 +03:00
jocoand
27a50ca765
Replace MaterialDialog with AlertDialog in SimpleMessageDialog.kt (#13548)
* Migrate to AlertDialog in SimpleMessageDialog.kt

* Use apply to prevent double show

* Use AlertDialog message directly

* Make button param non-null

* Use setMessage method

* Use AlertDialog method

* Fix test
2023-04-15 09:12:31 +03:00
Nikhil Gajwani
8ef86c12d4
Replace MaterialDialog with AlertDialog (#13525)
* Replace MaterialDialog with AlertDialog

- Specifcally, in the files CardTemplateEditor which necessitated changing it in other places
- Thus in DiscardChangesDialog and whoever else called the function DiscardChangesDialog.showDialog
- Thus in NoteEditor

* Remove deprecations, they cause build failures

* Feedback

- Remove unneeded assertion
- Add assertion to make sure  View is present within Dialog
- Other minor cleanup
2023-04-11 14:31:41 +03:00
marv
4fbce501dd
Add Override to Always Display Answer Button in Card Preview (#13577)
* Add override for answer button in preview

* Change LinearLayout to View in getting answer bar

* Add bottom bar override for multi card previewer
2023-04-11 08:27:40 +03:00
Ashish Yadav
d83de4410b fixed UI for log out screen allowing access to log out button 2023-04-11 04:35:11 +01:00
pratyaksh1610
5371a7e495 added product flavor to debug info 2023-04-09 18:05:23 -05:00
David Allison
ee3d1348e5 fix: crash on Check Media
A lateinit callback wasn't defined

Fixes 13527
2023-04-09 07:47:58 +03:00