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

16168 Commits

Author SHA1 Message Date
Arthur Milchior
599bcebfb0 NF: Conversion to nullable, then non null simplified 2022-08-18 20:14:12 -05:00
David Allison
7c64786676 refactor: Convert RetryRule to Kotlin
com.ichi2.anki.tests.libanki.RetryRule
2022-08-18 19:26:17 -05:00
David Allison
04746739d7 refactor: Rename RetryRule.java to .kt
com.ichi2.anki.tests.libanki.RetryRule
2022-08-18 19:26:17 -05:00
Nishant
7b1779852c Removed getLastListElement and tests 2022-08-18 19:11:48 -05:00
MrPenguins
7673c410ce Fixed the bug that filtered/custom study decks don't show in the Card browser 2022-08-18 18:38:35 -05:00
Mohd Raghib
e0ff9d3533
[KotlinCleanup] CardBrowser (#11457)
* cleanup - use `?.`

* cleanup - IDE lint

* cleanup - use `isNotEmpty`

* cleanup - if -> when
2022-08-18 18:38:14 -05:00
Arthur Milchior
21196d1389 NF: factorize unmondReceiver creation 2022-08-18 18:22:02 -05:00
Nishant Bhandari
670b0fdd98
[Enhancement] Matched the color of statusbar to actionbar & navbar to background. (#11236)
* Set statusbar color in theme_black.xml
* Set statusbar & navbar color in theme_dark.xml
* Set statusbar & navbar color in light & plain theme
* Setting navbar color programmatically.
* Setting statusbar color same as actionbar.

Co-authored-by: Mike Hardy <github@mikehardy.net>
2022-08-18 16:48:35 -05:00
Jaivardhan Shukla
c3b95c65fb
Added custom layout to the spinner adapter in the card browser activity to prevent the overlapping of various interactive components on the screen (#10968)
* Create spinner_custom_layout.xml
* Update styles.xml
* Update CardBrowser.kt

Co-authored-by: Mike Hardy <github@mikehardy.net>
2022-08-18 16:42:52 -05:00
lukstbit
6cdeee1cb7 Fix onActivityResult deprecation for StudyOptionsActivity 2022-08-18 16:26:23 -05:00
Akshit Sinha
a2eef40136
Modify findNotes() to use V16 searchNotes() function (#11908)
* Add `findNotes` function in `CollectionV16` new backend's searchNotes
Modify SearchNotes to be able to use both legacy and V16 functions
change ordering key for notes, and use JvmOverloads instead of overriding

* Fix config key, make query non-null
2022-08-18 16:17:08 -05:00
David Allison
2942f7f6ec refactor: Convert StdModels to Kotlin
com.ichi2.libanki.StdModels
2022-08-18 16:06:12 -05:00
David Allison
b57f1dd32c refactor: Rename StdModels.java to .kt
com.ichi2.libanki.StdModels
2022-08-18 16:06:12 -05:00
David Allison
9fa8b0235f refactor: Convert MathFunctionAtom to Kotlin
com.wildplot.android.parsing.AtomTypes.MathFunctionAtom
2022-08-18 15:59:00 -05:00
David Allison
68ff486934 refactor: Rename MathFunctionAtom.java to .kt
com.wildplot.android.parsing.AtomTypes.MathFunctionAtom
2022-08-18 15:59:00 -05:00
David Allison
0e7f001bfb perf: testAnswerCard - waiting on thread
`wait` uses Object.wait, we wanted `Thread.join()
2022-08-18 15:53:26 -05:00
lukstbit
9fc2d1c263 Fix save search in CardBrowser when dialog has no list 2022-08-18 15:51:27 -05:00
David Allison
396f5341fd refactor: Convert DeckConfig to Kotlin
com.ichi2.libanki.DeckConfig
2022-08-18 15:46:32 -05:00
David Allison
983086e903 refactor: Rename DeckConfig.java to .kt
com.ichi2.libanki.DeckConfig
2022-08-18 15:46:32 -05:00
oyeraghib
b13f03b191 cleanup: replace TextUtils for checking empty or null
removed the `Kotlin Cleanup` here even though TextUtils import is still present in the file because it is needed for the use case of `TextUtils.TruncateAt.END`
2022-08-18 15:42:00 -05:00
David Allison
e230b5cd64 refactor: Convert DBTest to Kotlin
com.ichi2.anki.tests.libanki.DBTest
2022-08-18 15:37:42 -05:00
David Allison
1767ed44a9 refactor: Rename DBTest.java to .kt
com.ichi2.anki.tests.libanki.DBTest
2022-08-18 15:37:42 -05:00
Brayan Oliveira
9ad1f5d940 Optimize NumberRangePref call change
Reduce the cost of converting its value from a string to Int and vice-versa

This is done by calling `callChangeListener` manually. Previously, it was called on `super.OnDialogClosed()`, which passed the value as a string
2022-08-18 15:37:12 -05:00
Brayan Oliveira
e9678d742f Fix crash if NumberRangePref value is empty on close 2022-08-18 15:37:12 -05:00
David Allison
fc96b0671c refactor: Convert CollectionAssert to Kotlin
com.ichi2.testutils.libanki.CollectionAssert
2022-08-18 15:32:24 -05:00
David Allison
97d1f9e3ac refactor: Rename CollectionAssert.java to .kt
com.ichi2.testutils.libanki.CollectionAssert
2022-08-18 15:32:24 -05:00
David Allison
1a1e937a38 refactor: Convert LayoutValidationTest to Kotlin
com.ichi2.anki.tests.LayoutValidationTest
2022-08-18 15:26:32 -05:00
David Allison
175f308a9d refactor: Rename LayoutValidationTest.java to .kt
com.ichi2.anki.tests.LayoutValidationTest
2022-08-18 15:26:32 -05:00
David Allison
d1919091ad refactor: Convert FilteredDeckUtil to Kotlin
com.ichi2.testutils.libanki.FilteredDeckUtil
2022-08-18 15:21:29 -05:00
David Allison
190a43f3c0 refactor: Rename FilteredDeckUtil.java to .kt
com.ichi2.testutils.libanki.FilteredDeckUtil
2022-08-18 15:21:29 -05:00
David Allison
4a9a28cbdd refactor: Convert ImportingTest to Kotlin
com.ichi2.libanki.ImportingTest
2022-08-18 14:49:17 -05:00
David Allison
84ff857ed3 refactor: Rename ImportingTest.java to .kt
com.ichi2.libanki.ImportingTest
2022-08-18 14:49:17 -05:00
David Allison
f3e56be471 refactor: Convert ProductionCrashReportingTreeTest to Kotlin
com.ichi2.anki.ProductionCrashReportingTreeTest

Needed to fix 'testProductionLogTag'
2022-08-18 14:42:59 -05:00
David Allison
6675bc6652 refactor: Rename ProductionCrashReportingTreeTest.java to .kt
com.ichi2.anki.ProductionCrashReportingTreeTest
2022-08-18 14:42:59 -05:00
David Allison
65a49343d4 refactor: Convert MediaTest to Kotlin
com.ichi2.anki.tests.libanki.MediaTest
2022-08-18 14:36:16 -05:00
David Allison
102c1bb4dd refactor: Rename MediaTest.java to .kt
com.ichi2.anki.tests.libanki.MediaTest
2022-08-18 14:36:16 -05:00
David Allison
0b3bfda242 refactor: Convert AbstractSchedTest to Kotlin
com.ichi2.libanki.sched.AbstractSchedTest
2022-08-18 14:00:14 -05:00
David Allison
fbf7b679c4 refactor: Rename AbstractSchedTest.java to .kt
com.ichi2.libanki.sched.AbstractSchedTest
2022-08-18 14:00:14 -05:00
Damien Elmes
efaefe35f3 Fix crash in new schema when user tries to change notetype of card
+ make the field/card map non-null, as null values were not being used
outside tests
2022-08-18 13:41:42 -05:00
oakkitten
a5adb1ad21 Remove workaround in SwipeDismissBehaviorFix
This removes the workaround which prevented other views from being moved
while trying to move the snackbar. Instead, BaseTransientBottomBar
.Behavior logic is restored.

The removed workaround was applicable to SwipeDismissBehavior. The idea
was taken from an old StackOverflow featuring an old version of
Behavior. It worked by checking by only ever intercepting gestures if
the finger is currently on top of the snackbar.

BaseTransientBottomBar.Behavior, which Snackbar.setBehavior expects,
overrides canSwipeDismissView, and checks if the child is
SnackbarBaseLayout. canSwipeDismissView is called by the original
ViewDragHelper.Callback; since we have rolled out our own, it's best to
inline this check.
2022-08-18 13:36:36 -05:00
oakkitten
a44e32b30b Simplify setting snackbar behavior
Previously, snackbar behavior was set by by changing behavior of view's
CoordinatorLayout.LayoutParams. This came with a few downsides:

  * We had to set it in a Snackbar.Callback. Snackbar's original
    behavior is created when it is shown, besides, we needed the
    original listener.
  * It required a few casts.
  * We had to steal the original listener since it is useful for
    pausing the snackbars.

With this, behavior is set “the official way”, by calling
Snackbar.setBehavior. This comes with the only downside:

  * Snackbar.setBehavior expects a BaseTransientBottomBar.Behavior,
    which extends SwipeDismissBehavior, so we get it on the superclass
    list. It seems that this class wasn't meant to be subclassed.

While now we have a funny class on the parent list, setting behavior
“the official way” simplifies the code quite a bit, so this is probably
a worthwhile change.
2022-08-18 13:36:36 -05:00
oakkitten
be4861c2fa Fix snackbar briefly flickering while settling
This glitch is quite rare.
2022-08-18 13:36:36 -05:00
oakkitten
aab5846c3e Set snackbar corner radius to 8dp
This is the default corner radius for Android 11 UI elements such as
notifications, dialogs, etc.
2022-08-18 13:36:36 -05:00
oakkitten
e36376451a Fix snackbar margins when insets change 2022-08-18 13:36:36 -05:00
oakkitten
b0cd6b1189 Call the listener in SensibleSwipeDismissBehavior
The listener ultimately manages snackbars, including their removal after
the duration has passed. Properly informing it of drag events makes it
possible for it to pause the timer while the snackbar is moved, etc.
2022-08-18 13:36:36 -05:00
oakkitten
6af6f76039 Implement SensibleSwipeDismissBehavior
SensibleSwipeDismissBehavior is more a fix for the inconsistent behavior
of SwipeDismissBehavior, rather than a custom implementation.
This addresses the following issues:

  * When the snackbar is swiped to the right, its opacity changes,
    but not when swiped to the left;

  * When moving the snackbar to dismiss it, the target distance
    calculation does not take margins into account, which makes the
    snackbar briefly appear stuck near the edge;

  * Any amount of horizontal velocity will dismiss the snackbar,
    which can result in user dismissing the snackbar even though they
    didn't want to;

  * If you drag the snackbar to the right, and then flinging it to the
    left, it will suddenly change course and start moving to the right.
2022-08-18 13:36:36 -05:00
oakkitten
4b74d24d51 Refactor Snackbars 2022-08-18 13:36:36 -05:00
oakkitten
0cf4ff0b7b Streamline snackbar creation
This changes the way snackbars are created. Instead of calling a
function with many arguments, the new methods consistently only take
text, duration, and a builder block--whether it is called on an
activity or a view. I chose builder pattern instead of call chaining as
it makes sure that the snackbar is actually shown in the end.

Note that if showSnackbar is called on an Activity that does not have a
view with id root_layout--which does not allow proper placing and
interaction with snackbars--a runtime exception will be intentionally
thrown in a debug build. Release builds will show a toast with the
contents of the snackbar instead.

Some durations were changed, notably, Card browser's snackbar that allow
searching in all decks now stay until dismissed. This is something user
may want to do at any time later; and if the snackbar is in the way,
they can dismiss it by swiping.

In com.ichi2.anki.CoroutineHelpersKt.launchCatchingTask, a few unrelated
to this change TODO comments were added.
2022-08-18 13:36:36 -05:00
oakkitten
215077ccfb Fix snackbar sitting right on top of answer buttons 2022-08-18 13:36:36 -05:00
oakkitten
147770db0c Do not show snackbars over toolbar 2022-08-18 13:36:36 -05:00