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

17537 Commits

Author SHA1 Message Date
Arthur Milchior
9aa7585ed6
Adding develepor options to add fake media (#13854)
* Add a dev setting to add medias

* fix some issues with the "Create fake media" dev options

fixes:
1. the preferences should be persistent in order to have their values saved so `Create the files` can work
2. A toast is shown instead of a snackbar because it is more visible if a dialog is active
3. Use `numberOfFiles` instead of `numberOfFilePreference` in the dialog message

the rest of the changes are nitpicks

* Fix minor issues

Append _key to the new preferences key names to be similar to other
keys.
Fix number of files shown in the success toast.

---------

Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
2023-06-08 11:28:09 -03:00
Brayan Oliveira
c84da56d09 Change preference category title color on the light theme
The dark shade it had wasn't very attractive

Contrast ratio of new text is over 4.5, i.e. good enough
2023-06-08 12:52:59 +03:00
Sanjaykumar Sargam
2604feba96 move cursor to end 2023-06-05 17:49:56 -03:00
Damien Elmes
043ded7876 Catch some attempts to access UI inside withCol, and col within UI thread
If detected, shows an IDE lint.

- Catches calls to col.* inside AnkiActivity contexts.
- Catches calls to methods of classes derived from AnkiActivity, eg

```
withCol {
  someDeckPickerMethod()
}
```

- UI classes that don't inherit from AnkiActivity are not caught unless
they are also annotated with @UiThread. Eg SetNotetypeListener in
NoteEditor references col, but is not caught without an extra annotation.

It might be best to wait until 2.16 is out (and any quick follow-up
releases to address the inevitable regressions) before we start addressing
these issues in bulk; for now the code might be better left as-is unless
it's to address a known bug someone has reported.

Related: #13944, #13942, #13936
2023-06-04 07:00:16 -03:00
Damien Elmes
52a3ea9d33 Remove launchWithCol()
Code inside a withCol() block should not modify the UI, as it runs on
a background thread. withCol() should fetch and/or mutate collection
data, and then UI operations/program state changes should be performed
outside the withCol block, so they're serialized on the main thread and
the risk of race conditions is minimized. Recently mentioned on
https://github.com/ankidroid/Anki-Android/pull/13886#issuecomment-1555407973

launchWithCol() makes it a bit too easy to accidentally run UI code in
the background thread, as it provides both an async context and a collection
at the same time, and the user will be tempted to do both fetch-from-col
and update-UI steps inside the block. Removing it means a few extra characters
at each call site, but I think it's a bit less error-prone.
2023-06-03 21:10:39 -03:00
lukstbit
d39436da73 Fix parent config not being applied on child decks in deck options 2023-06-02 15:41:47 -03:00
Ashish Yadav
4bf2084191 ellipsize the deck name if too lengthy 2023-05-31 19:15:54 -03:00
Sanjaykumar Sargam
ddce7e40de immediate dialog after selecting note type 2023-05-30 17:42:41 -03:00
AnkiDroid Translations
84c126381f Updated strings from Crowdin 2023-05-30 19:53:53 +03:00
Robozinho
56da7fae2c
NF: clean study options nulls (#13877)
* lateinit textDeckname

* lateinit deckInfoLayout

* lateinit textETA

* lateinit textCongrats

* lateinit buttonStart

* lateinit textDeckDescription

* lateinit more variables

* make col null safe

* make mFullNewCountThread call safer

* remove null early return

inflate() takes a nullable "root" argument so there is no reason to early return

the documentation says that the root argument is an "*******Optional******* view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)"

so the view is inflated anyway if you give a null root (or container)

Asked by @Arthur-Milchior
2023-05-30 04:26:36 -03:00
Prince kushwaha
6c5c663917 Changed Material Dialog with Alert Dialog for ModelEditorContextMenu.kt 2023-05-26 12:52:52 -03:00
sargamgayatri0803@gmail.com
dcebd49032 IntegerDialog showing keyboard 2023-05-26 12:50:36 -03:00
Ashish Yadav
5dd9ebacdc using activity.package to fix the authority issue while exporting col 2023-05-25 23:40:38 +01:00
snowtimeglass
10812cea19 Use "Finish" as Timebox negative button label
The current label of the negative button of "Timebox reached" dialog is "Close",
but it misleads as if it merely closes the dialog.
(It actually finishes the review session and shows the deck picker screen.)

This commit will replace the label with "Finish",
which is used on the counterpart dialog in Anki Desktop.
The string is reused from Anki Desktop.

Incidentally, this commit will also add the title comment
to the section of Timebox in 02-string.xml, for organization.
2023-05-24 10:50:14 -03:00
AnkiDroid Translations
c25579a645 Updated strings from Crowdin 2023-05-22 06:33:00 +03:00
Sanjaykumar Sargam
2076bcb698 Replaced Toast with Snackbar in AnkiDroidJSAPI.kt 2023-05-20 08:48:37 -03:00
David Allison
f27dc86645 hack: workaround .nomedia being mutated
During a storage migration, we had a case where `.nomedia` failed the
 content equality checks.

We do not know why, could not reproduce this and could not see it in
 any further crash reports.

To work around this case, log and ignore the failure.
We log to further understand the issue.

Fixes 13807
2023-05-18 18:00:14 +03:00
David Allison
c588042bb1 improve exception if files not equal
We didn't include the file name

Improves 13807
2023-05-18 18:00:14 +03:00
lukstbit
66320038eb Add International Phonetic Alphabet as a note field language hint option
This wasn't available from Locale.getAvailableLocales() but creating a new locale using "und-fonipa" as a language tag
seems to be understood as IPA. Will appear in the language hint dialog as "IPA Phonetics" and will work with GBoard.

See https://en.wikipedia.org/wiki/International_Phonetic_Alphabet#IETF_language_tags
2023-05-17 15:07:19 -03:00
Robozinho
a064351ca1 add feedback to about buttons 2023-05-16 20:55:10 -03:00
sargamgayatri0803@gmail.com
cfc12ec917 cursor to end 2023-05-16 18:28:42 +03:00
Arthur Milchior
3fe7c1a2b3
NF: simplify some requirePreference calls (#13860) 2023-05-15 19:41:49 -03:00
Arthur Milchior
00d2d9a864 NF: refactor Creating hexadecimal string 2023-05-15 15:17:58 -03:00
Sanjaykumar Sargam
5d66753d8f EditTextPreference -> AutoFocusEditTextPreference 2023-05-15 10:36:48 -03:00
Arthur Milchior
94328239e6 NF: Refactor as DeckPicker
This is equivalent (at least as long as `when (selectedoption)` is exhaustive),
and more readable.
2023-05-15 09:21:08 -03:00
Ashish Yadav
165c74ee6d orientation lock for gesture picker dialog 2023-05-15 06:48:14 -05:00
Arthur Milchior
82951b853b NF: add documentation for Path 2023-05-15 06:46:46 -05:00
Mike Hardy
1e95d1ce85 Bumped version to 2.16.0beta2 2023-05-13 22:38:24 +00:00
AnkiDroid Translations
dd325625d9 Updated strings from Crowdin 2023-05-13 17:37:22 -05:00
oakkitten
b268a933e4
Fix UI being in bad state when storage migration fails (#13774)
When migration fails, we used to be stuck in a kind of a limbo:
the migration is considered done (failed, but done) by the service,
but `userMigrationIsInProgress` still returned true, so the UI was not
updated to reflect the state of the migration.

To overcome the issue, this introduces the state of “migration is
paused due to an error”, which is saved in shared preferences.
In this state, the toolbar shows the same migrate button that offers
to resume migration, and the sync icon is hidden.

A few TODOs were also added.

Co-authored-by: Mike Hardy <github@mikehardy.net>
2023-05-13 13:57:51 -05:00
Mike Hardy
330e585985
Dependency updates 20231305 (#13846)
* build(deps): bump com.fasterxml.jackson.core:jackson-databind

Bumps [com.fasterxml.jackson.core:jackson-databind](https://github.com/FasterXML/jackson) from 2.12.0 to 2.15.0.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* build(deps): bump org.robolectric:robolectric from 4.10.1 to 4.10.2

Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.10.1 to 4.10.2.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.10.1...robolectric-4.10.2)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  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.3 to 3.22.4.

---
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 com.google.protobuf:protobuf-kotlin

Bumps com.google.protobuf:protobuf-kotlin from 3.22.4 to 3.23.0.

---
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 com.github.triplet.play from 3.8.2 to 3.8.3

Bumps com.github.triplet.play from 3.8.2 to 3.8.3.

---
updated-dependencies:
- dependency-name: com.github.triplet.play
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump androidx.core:core-ktx from 1.10.0 to 1.10.1

Bumps androidx.core:core-ktx from 1.10.0 to 1.10.1.

---
updated-dependencies:
- dependency-name: androidx.core:core-ktx
  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-05-13 13:45:08 -05:00
oakkitten
4e708502c2
Refactor AggregateException, making it translatable, & sligtly fix up the migration failed notification (#13762)
* test: aggregateExceptionStackTrace

Requested? in issue 13667

* AggregateException: Define message + localizedMessage

Requested in issue 13667

* Refactor AggregateException

This also creates concepts of translatable strings and translatable
exceptions.

I decided to drop the logic of former AggregateException.raise, which
would return the one exception from the given list if it only had one
element, or create a new AggregateException, because:

  * the logic is only used in two places, and:

  * in non-trivial cases which involve the creation of translatable
    strings, we'd want to create them lazily as they might not be
    always needed. This might be done, perhaps, with something like
    the following:

        fun getSingleOrAggregateException(
            causes: List<Exception>,
            ifManyCauses: TranslatableAggregateException.MessageBuilder.() -> Unit
        ): Exception {
            require(causes.isNotEmpty()) { "The list of exceptions was empty" }
            return if (causes.size == 1) {
                causes.single()
            } else {
                val messageBuilder = TranslatableAggregateException.MessageBuilder()
                ifManyCauses(messageBuilder)
                TranslatableAggregateException(messageBuilder.message, messageBuilder.translatableMessage, causes)
            }
        }

    I suggest that we do not employ complications like these unless
    AggregateException is extensively used in the codebase.

* Show big, friendly error text in migration failed notification

* Remove multiple-argument `TranslatableString.by`

As discussed in the PR
https://github.com/ankidroid/Anki-Android/pull/13762#discussion_r1182926595,
this method was not subject to string format linting.

Plus minor renaming.

---------

Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
2023-05-13 13:28:38 -05:00
AnkiDroid Translations
773a8b59b3 Updated strings from Crowdin 2023-05-13 13:28:17 -05:00
David Allison
868b6c740c fix: IndexOutOfBoundsException: Inconsistency detected (maybe)
This is fixed by stopping the mutating m[Current]DeckList

This should fix the issue:
`IndexOutOfBoundsException: Inconsistency detected. Invalid item position [N]`

Fixes 13794
2023-05-13 12:56:51 -05:00
David Allison
519da438d0 refactor: make processNodes pure
This is a next step in stopping mutation of `m[Current]DeckList` lists
2023-05-13 12:56:51 -05:00
David Allison
76bbd76e26 refactor: remove 'suspend' from findDeckPosition
We did not need to access the collection for this.
We have a cache of the mapping, which was produced at the same
  time as `mCurrentDeckList`

Which in turn removes a number of 'suspend' calls throughout the code

Cleanup for 70151c563e
2023-05-13 12:56:51 -05:00
David Allison
126489d627 refactor: detecting isCollapsed
* more efficient (no need to check all parents, just immediate)
* simpler code
2023-05-13 12:56:51 -05:00
David Allison
25c050d3de refactor: simplify 'lrn/new/rev' calculations 2023-05-13 12:56:51 -05:00
David Allison
537d8ccfd8 docs: minor backend inconsistency 2023-05-13 12:56:51 -05:00
David Allison
b9111e2b67 fix: 'hasSubdecks' [new backend]
Before this change, a single deck in the list set 'hasSubdecks'
which caused padding to appear. This should not have been the
case
2023-05-13 12:56:51 -05:00
Arthur Milchior
9311b7262a NF: clarify a constant name 2023-05-13 12:53:38 -05:00
Arthur Milchior
c86f6def97 NF: Advanced Fragment code follow appearance order
While adding an advanced setting, I found confusing that the code appears in an
order that is not related to the order in the actual presentation. So I reorder
it.

Actual change will appear in a distinct PR.
2023-05-13 11:04:32 -03:00
Sanjaykumar Sargam
3ea5c51d01 Video is playing 2023-05-12 13:59:19 +05:30
Sanjaykumar Sargam
1d431cafe4 DiscardChangesDialog is closed in one click 2023-05-11 04:08:44 +01:00
David Allison
0a572ba631 Fix TODOs/conditionally skip confirmation dialog
This PR skips the 'Are you sure?' warning if the user is syncing
and their collection is safe

This is primarily documentation, the previous code has one minor
bug in that a user could be preserving legacy storage AND not syncing
AND had the ability to `MANAGE_EXTERNAL_STORAGE` then the 'backup'
dialog was shown when it was not necessary

Mostly making use of newer documented methods in `ScopedStorageService`

Fixes 13663
2023-05-10 20:55:01 -03:00
David Allison
ca4ba96709 extract: userIsPromptedToDeleteCollectionOnUninstall 2023-05-10 20:55:01 -03:00
Sanjaykumar Sargam
149c4b303b fix item getting bold 2023-05-10 19:46:04 -03:00
AnkiDroid Translations
8e17b08ee5 Updated strings from Crowdin 2023-05-10 20:38:30 +03:00
Ashish Yadav
0c31df5fe7 Added remember settings to your connection is metered dialog 2023-05-10 19:38:30 +03:00
AnkiDroid Translations
c5a05db1bd Updated strings from Crowdin 2023-05-10 19:04:38 +03:00