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

9629 Commits

Author SHA1 Message Date
Robozinho
2e11eeb33e Replace MaterialDialog with AlertDialog 2023-03-28 06:46:43 +03:00
David Allison
8f9d5c4f66 refactor: toggleStylus - Kotlin Cleanup
A review comment of mine on 13475 which wasn't worth blocking the PR over
2023-03-27 20:44:27 -03:00
Robozinho
d03d544c6e fix deprecation and unchecked cast 2023-03-27 19:59:51 -03:00
naong
66ba7b1f2a
Whiteboard - Stylus Only Mode (#13475)
* NF: Whiteboard - Stylus Only Mode

This function allows you to write with only the stylus pen when using a stylus pen such as the S-Pen. Finger gestures use scroll and button controls only.
This function have a toggle action button and a menu.

Implemented remembering stylus mode state function by adding stylus column in whiteboardState table.
Fixed meta db bug.

---------

Co-authored-by: Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com>
2023-03-27 23:49:11 +01:00
Robozinho
3578675a4a
Fix some activityResult deprecations (#13495)
* Fix deck options activityResult deprecation

* Fix activityResult deprecation

request code wasn't used

* Add log

* add requested changes
2023-03-27 23:23:06 +01:00
Robozinho
5b5e82a765
Use snackbar instead of toast on note editor add note (#13515) 2023-03-27 19:15:56 -03:00
Robozinho
7ab289a0ee Remove unused method 2023-03-27 21:46:26 +01:00
Arthur Milchior
2e5ef904c8 NF: Rename handleStoragePermissionsCheckForCheckMedia
As @oakkitten noted, the name is misleading, since the function does not handle
anything.
2023-03-27 12:40:52 -05:00
David Allison
8f1984d6bd build: 'full' build with no manifest restrictions
A default build ('play') is not allowed MANAGE_EXTERNAL_STORAGE

We want a build with this permission so we can distribute it.

`amazon` removes the camera permission, so it is not appropriate

So add a new flavor: 'full' which has BOTH camera & storage permissions

Related: 13431
2023-03-27 06:32:30 -03:00
Ashish Yadav
f83f19004d fixed check for condition 2023-03-26 21:17:18 +01:00
AnkiDroid Translations
c7a9042822 Updated strings from Crowdin 2023-03-26 11:24:23 -05:00
Mike Hardy
9c950f4e17 Fix dnagling reference to removed string 2023-03-25 21:58:08 -05:00
snowtimeglass
f8f0146287 Rewrite the string for Debug info toast
old: about_ankidroid_successfully_copied_debug
new: about_ankidroid_successfully_copied_debug_info
2023-03-25 19:19:00 -05:00
snowtimeglass
6555264de1 For Reviewer actions, reuse Anki Desktop strings
- For feedback-toast message to Reviewer actions, reuse strings of Anki Desktop
- Use new strings instead of ones of Anki Desktop, as needed
2023-03-25 19:19:00 -05:00
snowtimeglass
629d878b12 Reconstruct strings for Reviewer-actions' feedback
Reconstruct the strings for the feedback-toast message to Reviewer actions

Basically, use strings on Anki Desktop instead of the current ones. Create new ones as needed.
For Bury and Suspend, I set the style described in the following comment as a goal:
  https://github.com/ankidroid/Anki-Android/pull/12446#issuecomment-1279763351

------------------------------

- Replace `<string name="buried_card">Card buried</string>`
        with `<string name="card_buried">Card buried.</string>`

- Remove `<string name="buried_note">Note buried</string>`
   (Instead of the string, its counterpart on Anki Desktop will work on the toast.)

- Remove `<string name="deleted_note">Note deleted</string>`
   (Instead of the string, its counterpart on Anki Desktop will work on the toast.)

- Remove `<string name="suspended_card">Card suspended</string>`
   (Instead of the string, its counterpart on Anki Desktop will work on the toast.)

- Replace `<string name="suspended_note">Note suspended</string>`
        with the following code:
                `<plurals name="note_suspended"
                        <item quantity="one">%d card suspended.</item>
                        <item quantity="other">%d cards suspended.</item>
                 </plurals>`

------------------------------
2023-03-25 19:19:00 -05:00
snowtimeglass
44bff3d75b Change the word order the toast messages
Change the word order of some of the toast messages

"[Subject] (omission of [be Verb]) [Past participle]" word order is used in Anki Desktop and AnkiDroid, but it isn't on some strings of AnkiDroid

before change  -->   after change
-------------------------------------------------
"Buried card" --> "Card buried"
"Buried note" --> "Note buried"
"Deleted note" --> "Note deleted"
"Suspended card" --> "Card suspended"
"Suspended note" --> "Note suspended"
"Created deck"  --> "Deck created"
"Renamed deck"  --> "Deck renamed"
"Copied debug information to clipboard" --> "Debug information was copied to clipboard" (no omission of be Verb)
-------------------------------------------------
2023-03-25 19:19:00 -05:00
Ashish Yadav
94dae55672 exit application on delete collection click to restart all activities. 2023-03-25 19:18:42 -05:00
David Allison
56e0a24f54 Storage: Restore From Backup if uninstalled
If a user has uninstalled the app, one of the options should
be to restore from a .colpkg

Use `ankiDroidDirectoryOverride` as code uses the location in
 CollectionHelper rather than `col.path`. Defining a temporary
 collection in `CollectionManager` was deemed to be too challenging

Tested with 'Don't keep activities' and failures in the import copy

Issue 5304
2023-03-25 19:18:16 -05:00
David Allison
7cb432c4c1 fix: showDialogFragment
Exception: java.lang.IllegalStateException: Must be called from main thread of fragment host
2023-03-25 19:18:16 -05:00
David Allison
e43d38ecde fix: ImportReplace - use current collection path
`getCollectionPath` should be used when the collection is closed
2023-03-25 19:18:16 -05:00
David Allison
4d7eb1ea57 refactor: extract 'Import' from DeckPicker 2023-03-25 19:18:16 -05:00
David Allison
136cfb3f8a Scoped Storage: Handle storage being revoked
If a user uninstalls AnkiDroid, `preserveLegacyStorage` no longer
works

This means they have a deckPath of `/storage/emulated/0/AnkiDroid`
which can no longer be accessed.

Their data exists, but cannot be accessed unless:
* They restore from AnkiWeb
* They have a colpkg
* They manually copy the folder over
* They install a non-Google-Play copy

Options:
* Restore from AnkiWeb
* Restore folder access
   (https://github.com/ankidroid/Anki-Android/wiki/Full-Storage-Access)
* Restore backup (Hidden - Not Implemented)
* Get Help (Link to: Google Group)
* Delete collection and create a new one

Issue 5304
2023-03-25 19:18:16 -05:00
AnkiDroid Translations
5c06c1806f Updated strings from Crowdin 2023-03-25 19:17:38 -05:00
AnkiDroid Translations
92c42cc825 Updated strings from Crowdin 2023-03-24 14:52:31 -05:00
David Allison
be62538feb fix: Errors migrating from a notification
If a migration requires a sync, and a sync completes when the app is
 paused, a notification occurs prompting the user to migrate.

This is handled by `DialogHandler`, which runs in AnkiActivity.onResume
BEFORE `loadDeckCounts`.

This races with closing the collection for a storage migration.

Instead, start the task and allow it to be stopped.

Issue 5304
2023-03-24 11:12:48 -05:00
David Allison
d385361a25 fix: Remove sync col access from renderPage
Caused bugs when performing a storage migration after syncing
2023-03-24 11:12:48 -05:00
David Allison
4dab1b2f8e Dialog: 'media sync unavailable' before migration
We need a media sync before a storage migration.

If this has been disabled, it is the user's responsibility
to perform a sync before this migration occurs

There are currently two reasons:

Fetch media on Sync is set to:
* 'Only if unmetered' & connection is metered
* Never

Issue 5304
2023-03-24 11:12:48 -05:00
David Allison
3b3e1fcdc7 Scoped Storage: Enforce Media Sync Before Migration
We need to move the user's data to /Android/ to handle scoped storage
changes. Before we perform this migration, we should ensure that users
data is safe. To do this, we enforce a sync.

A user should have completed a full media sync before the migration
occurs.

This ensures that their data is up to date and can be restored if
anything goes awry with the migration

Dialog wording as discussed on the Figma, with the exception of
changing 'sync' to 'media sync'

Issue 5304
2023-03-24 11:12:48 -05:00
David Allison
60fa3261c9 Add Async Operation for 'Migrate'
Displays a notification if the app is paused
otherwise performs the operation

Similar to 'DialogHandler', but doesn't require a dialog
2023-03-24 11:12:48 -05:00
David Allison
705949d831 DeckPicker: Add 'migrateStorageAfterMediaSyncCompleted' 2023-03-24 11:12:48 -05:00
David Allison
fab82bc262 DeckPicker: Add 'onMediaSyncCompleted' 2023-03-24 11:12:48 -05:00
Sanjay Sargam
a89502c9fb
Show warning on reset to default button in AppBar (#13476) 2023-03-24 09:05:09 -05:00
Prince kushwaha
c96e2eff9e
Changed Material Dialog with Alert Dialog for Toolbar.kt (#13467)
* Changed Material Dialog with Alert Dialog for Toolbar.kt

* fix minor issues
2023-03-24 11:57:27 +02:00
snowtimeglass
2198f6e840 Increase snackbar maximum lines from 2 to 4 2023-03-24 06:05:22 -03:00
David Allison
aa34a6f8b7 Allow user to disable 'storage migration' reminder
Checkbox to disable permanently if `timesStorageMigrationPostponed > 1`

+ Warning that uninstalling the app will delete/make storage inaccessible

Issue 5304
2023-03-23 21:38:09 -05:00
David Allison
aaedfb53da feat: Add checkBoxPrompt to AlertDialog
This differs from the async prompt as it does not
remove the 'message' parameter
2023-03-23 21:38:09 -05:00
David Allison
ee5e6ccad5 docs(AlertDialogFacade): fix error message 2023-03-23 21:38:09 -05:00
David Allison
3c5980803d Offer to migrate storage every 4 days
If a user doesn't migrate:
* Storage is slow
* They permanently lose access to their collection on uninstall

If the user does migrate:
* Storage is fast
* Data is deleted on uninstall (unless a user opts out)

We have a subset of users who are safe to migrate (syncing)
and want them to migrate ASAP so they get the speed benefits
while syncing

Display the dialog from showDialogThatOffersToMigrateStorage

Issue 5304
2023-03-23 21:38:09 -05:00
Prince kushwaha
c3d380ed78 Changed Material Dialog with Alert Dialog for CoroutineHelpers.kt 2023-03-23 19:37:35 +02:00
Robozinho
71e9e3f327
Fix startActivityForResult deprecation on NavigationDrawerActivity (#13479)
* Remove startActivityForResult usage

The result code was never used
2023-03-23 18:58:25 +02:00
Mike Hardy
c675e0d964
Dependency updates 20230323 (#13487)
* Bump org.jetbrains:annotations from 24.0.0 to 24.0.1

Bumps [org.jetbrains:annotations](https://github.com/JetBrains/java-annotations) from 24.0.0 to 24.0.1.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains:annotations
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.2.0 to 11.3.1

Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.2.0 to 11.3.1.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

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

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

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

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

* build(deps): bump androidx.recyclerview:recyclerview from 1.2.1 to 1.3.0

Bumps androidx.recyclerview:recyclerview from 1.2.1 to 1.3.0.

---
updated-dependencies:
- dependency-name: androidx.recyclerview:recyclerview
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* build(deps): bump androidx.sqlite:sqlite-framework from 2.3.0 to 2.3.1

Bumps androidx.sqlite:sqlite-framework from 2.3.0 to 2.3.1.

---
updated-dependencies:
- dependency-name: androidx.sqlite:sqlite-framework
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump androidx.activity:activity-ktx from 1.6.1 to 1.7.0

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

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

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

* build(deps): bump androidx.webkit:webkit from 1.6.0 to 1.6.1

Bumps androidx.webkit:webkit from 1.6.0 to 1.6.1.

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

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

* build(deps): bump org.mockito:mockito-inline from 5.1.1 to 5.2.0

Bumps [org.mockito:mockito-inline](https://github.com/mockito/mockito) from 5.1.1 to 5.2.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v5.1.1...v5.2.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-inline
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

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

Bumps `fragments_version` from 1.5.5 to 1.5.6.

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

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

---
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>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-23 10:11:40 -05:00
pratyaksh1610
09b3f0a2f5 change startup permission toast 2023-03-23 08:37:46 -05:00
AnkiDroid Translations
674a18ccd0 Updated strings from Crowdin 2023-03-23 08:11:16 -05:00
Prince kushwaha
8ecd6c3c9f Changed Material Dialog with Alert Dialog for ManageNotetypes.kt.kt 2023-03-21 06:45:13 +02:00
David Allison
23a173a1f3 fix: Allow 'WRITE_EXTERNAL_STORAGE' on Q
Tested and this works - makes code safer for users on Q
as they use the 'Public Directory'
2023-03-20 12:44:59 -05:00
David Allison
a6194e7592 refactor: rename 'app-specific' to 'app-private'
For a number of cases, not all

Requested in Review:

"Public Folder" for legacy storage
"App Private" for storage which is deleted on uninstall
2023-03-20 12:44:59 -05:00
David Allison
35a715d0aa Fix: performActionIfStorageAccessible
/AnkiDroid can be re-enabled via the following on a `play` build:

```
adb shell am compat disable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug
adb shell am compat disable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug
adb shell pm grant com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE
```

In one case `hasStorageAccessPermission` wasn't executed due to faulty assumptions.

Fix this and document the issue

Issue 5304
2023-03-20 12:44:59 -05:00
David Allison
8569db41aa remove unused field: 'LEGACY_STORAGE'
Now controlled via whether a user wants a 'play' build or not

Related to issue 5304
2023-03-20 12:44:59 -05:00
David Allison
56a195bf46 Bump to API 30 & enable MANAGE_EXTERNAL_STORAGE
MANAGE_EXTERNAL_STORAGE is for non-Google Play builds.

Google won't let us have the permission, but there's no reason
other stores + users have to suffer this decision.

This allows a Google Play user to restore their data if they uninstall
(uninstall, then download the APK and data is available again)

* Remove MANAGE_EXTERNAL_STORAGE from the manifest if targeting `play`

Version Codes & Outcomes:

1 < Q - force storage permissions as done previously (incl. Play Store)
2   Q - Users are unsafe and need a storage migration
        * MANAGE_EXTERNAL_STORAGE is unavailable
        * READ/WRITE_EXTERNAL_STORAGE is unavailable
3 > Q - Non-Play-Store users need MANAGE_EXTERNAL_STORAGE (*)
4 > Q - Play Store users are unsafe and need a storage migration

If a user is starting out and may request 'safe' permissions (1) (3)
Then we keep `deckPath` as a legacy path.

1) & 3) We do not allow access to the app until they give permission

----

Storage can be re-enabled after this change via:

```
adb shell am compat disable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug
adb shell am compat disable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug
adb shell pm grant com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE
```

on an API 30 emulator (or a non-AOSP emulator)

Related: Issue 5304
Fixes 13051 - targetSdkVersion 30 fixes this
2023-03-20 12:44:59 -05:00
David Allison
ef8169e539 refactor: Extract permission logic from DeckPicker
This logic will get more complex after scoped storage.
This makes it more testable

This hides complexity as permissions dialogs:
* May not be necessary (permissions already granted)
* Return permission granted/denied in an async fashion

Android provides no native way to know if permissions have been denied
permanently.

To work around this, we define a PermissionsManager which encapsulates
both concerns: `.requestDialog` returns the dialog state and accepts a
 callback if the method is async.

* Fixes a TODO where a permissions dialog is not shown

In order to use `registerForActivityResult`, registration needs to
occur on activity startup.

Uses `shouldShowRequestPermissionRationale` to determine if a
permission denial is temporary or permanent

Fixes a DeckPicker TODO on checking media
2023-03-20 12:44:59 -05:00