[Bug] RTL support for activity transition animations
Reproduction Steps
- From the deck list, go to the Card Browser or Statistics screen
- Return to the deck list (probably affects transitions between other activities as well)
Expected Result
When the UI is set to a RTL language, the new activity should appear from the left and then disappear to the left (i.e. the opposite as in LTR languages).
Actual Result
The new activity appears from the right, and disappears to the right like in LTR languages.
Debug info
2.15alpha36
Research
Enter an [x] character to confirm the points below:
- [x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
- [x] I have checked the manual and the FAQ and could not find a solution to my issue
- [x] I have searched for similar existing issues here and on the user forum
- [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
I want to work on this issue please can you elaborate more??
Can you read a RTL language? If not, it might be easier to start with a different issue. If you'd still like to try, see the first post in #8259 for an overview and how to force a RTL layout for other languages.
A first step would be to confirm that you can reproduce this behaviour.
No I don't Know to Read the Rtl language its just animation part so I think there is no need of language
No, it's not necessary, just makes it easier to test and to understand what should be changed.
But in that case go ahead and try to reproduce it, using the instructions in the issue I mentioned to force a RTL layout for English. Make sure you're using the latest alpha version or the master branch from Github.
ok then assign me the task
https://user-images.githubusercontent.com/76252038/113134565-95930500-923e-11eb-9399-e2e7edf8d8d8.mp4
sir do check is this correct???
Yes, this is the wrong behaviour I mentioned in the bug description. For RTL languages, the intended behaviour would be to mirror these animations horizontally.
ohh sorry sir so the activity's "In-transition" should be from right to left and "out transition" right to left . Right????
Yes. Essentially all left->right and right->left animations should be reversed for RTL.
sir I have created a separate animation file anim-ldrtl under res And I have entered the animation file and changed the behaviour of each file (i.e In slide_left_in I have placed property of slide_right_in and viceversa).I don't Know what to do next.
I'm in this area for other reasons and noticed that we are using ActivityTransitionAnimation in our source tree for these animations (or at least, we should use it for all animations)
Currently we have a LEFT and RIGHT defined as constants to specify an animation.
Following Android naming practices those constants should be renamed START and END so that the "idea" of RTL languages is built in
Then in the switch statement where the constants are used, the existing right and left animations should be selected appropriately depending on RTL status
I do not believe any other layouts or anything are required, and once the constant names are changed in Java the code won't compile if anyone is doing it wrong
Sir I have renamed LEFT AND RIGHT variables to START AND END how to implement in switch case we have to reverse the transition when switched from LTR to RTL and vice versa
in each of the indicated cases, you will need some programmatic way to determine if your locale is RTL or not, then select the correct animation. Figuring that out is the task.
Character.getDirectionality returns the Bi-directional (bidi) character type. Left-to-right text is a predictable type L and right-to-left is also predictably type R. BUT, Arabic text returns another type, type AL.
I added a check for both type R and type AL and then manually tested every RTL language Android comes with: Hebrew (Israel), Arabic (Egypt), and Arabic (Israel).
As you can see, this leaves out other right-to-left languages, so I was concerned that as Android adds these languages, there might have a similar issue and one might not notice right away.
So I tested manually each RTL language.
Arabic (العربية) = type AL Kurdish (کوردی) = type AL Farsi (فارسی) = type AL Urdu (اردو) = type AL Hebrew (עברית) = type R Yiddish (ייִדיש) = type R So it looks like this should work great:
public static boolean isRTL() { return isRTL(Locale.getDefault()); }
public static boolean isRTL(Locale locale) { final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0)); return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT || directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; }
this might help you to understand @vinishhub .
Thanks sir
https://user-images.githubusercontent.com/76252038/113726413-d9d84680-9711-11eb-8149-aeb0ae846a71.mp4
@eginhard I think now its ok