[Galaxy Note 4 Android Development (Snapdragon)] daxgirl:
Hello guys!

Since the update for lollipop started rolling out for Samsing devices, we have noticed that the RTL alignment of the email content in the Samsung Email client is no longer responsive to the csc feature we had used before. On builds up untill kitkat it was enough to add the following line <CscFeature_Email_AlignmentForRTL>true</CscFeature_Email_AlignmentForRTL> to the csc feature set and all would miraculously be OK. On Lollipop the method which sets the message layout direction (makeNewBodyContents4RTL) no longer responds to CSC feature, rendering that feature a dead stick method.

On new lollipop build for Note 4 and Note edge we have a different condition for proper message RTL alignment and that condition is setting the system to one of the RTL languages. Since some people prefer to use their device in English or other LTR language, this option is not always appealing to them. So here goes the fix. Now you can provide your users with an option to have RTL alignment in any system language. This will only affect RTL text. No worries for the LTR users.

Navigate to /smali/com/android/email/activity/MessageCompose.smali and search for the following code:

invoke-static {}, Lcom/android/email/util/EmailFeature;->isRTLLanguage()Z

move-result v11

if-nez v11, :cond_a

This is the one place in this method that checks if the system language is one of the RTL languages (Arabic, Hebrew, Farsi...) and according to that invokes method makeNewBodyContents4RTL().

So lets see the logic. If the user is using their phone in Arabic, this will invoke a boolean isRTLLanguage() in EmailFeature.class. That boolean will return TRUE for Arabic and therefore register V11 will get a value of 1. The condition states that if V11 is not equal to zero (and it is not, since it is 1), then use cond_a. Following down the line we can see that cond_a is invoking a method called makeNewBodyContents4RTL(). Which produces RTL aligned mail message if the FIRST CHAR (first letter) is in RTL language. So no worries for the LTR users.

So... if the user is using their phone in Italian (f.e...) the boolean isRTLLanguage() will return FALSE (0). So there will be no RTL alignment of the mail.

So what we will do is feed TRUE in ANY case to the V11 register. Like so. You need to add the line in blue:

invoke-static {}, Lcom/android/email/util/EmailFeature;->isRTLLanguage()Z

move-result v11

[COLOR="Blue"]const/16 v11, 0x1[/COLOR]

if-nez v11, :cond_a

That's it. You can also remove the line with invoke-static and move-result and just put const/16 v11, 0x1 instead. It doesn't matter how you do it. As long is that register gets 1 and not 0 under all conditions.

DO NOT change the conditions of the boolean isRTLLanguage() in EmailFeature.class because you will end up with ALOT of layout troubles in LTR languages. What the user needs is ONLY the RTL alignment for the body of the Email. So we solve it in the class that uses that method and NOT in the class that provides the boolean for a bunch of other classes in the app.

Cheers guys!

This thread is among other things dedicated to my friend [MENTION=3026895]DaOldMan[/MENTION] and his friend Bullmans (Shuchi) who have been struggling with this feature for a while now. Love you guys, you can move on now ;)