Git Product home page Git Product logo

Comments (12)

theSoenke avatar theSoenke commented on May 29, 2024 1

Hi @angelolloqui, I'm sorry for my delayed response. We're looking into this behavior now and I hope to provide an update early next week

from phrase-android.

DarkMinstrel avatar DarkMinstrel commented on May 29, 2024 1

In order to preserve CDATA when using Phrase, you need to enable this checkbox in your distribution settings:
image

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

BTW, you should make your code open source so we could fix it ourselves, unblocking us and simplifying your support

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

A little bit of extra info. If I get the string from Phrase.INSTANCE.repository.getString() (by using some reflection magic), the string comes with the proper HTML format, so it has been stored and read properly from the OTA itself. It seems that something is stripping it out between the read from repo and the getString on activity/fragment level (both having same output), probably the delegate or some other interceptor in the chain

Inside my fragment:

getString(R.string.social_feed_post_match_user_title, name, tenant)  // ❌ NO HTML
activity?.getString(R.string.social_feed_post_match_user_title, name, tenant)  // ❌ NO HTML
resources.getString(R.string.social_feed_post_match_user_title, name, tenant)  // ❌ NO HTML
applicationContext.getString(R.string.social_feed_post_match_user_title, name, tenant)  // ❌ NO HTML
Phrase.INSTANCE.repository.getString("social_feed_post_match_user_title")  // ✅ HTML included

In all of them I see the value from OTA, since I modified un purpose the local string to see if I am getting the local or the remote value.
If I remove Phrase.setup(this, Constants.phraseAppOtaDistributionId, Constants.phraseAppOtaSecret) from my app, then all of them return the proper HTML and the locally modified content (no OTA)

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

A little piece of extra info. It seems the bug is reproducible in 2.3.1 too, but maybe just in some devices. In particular I have managed to reproduce it in a Samsung Galaxy J7 with Android 8.1.0 and in an emulator with Android 11.
UPDATE: I have found out that it is language based... are you doing some sanity checks with the HTML that might not pass and remove the HTML in some cases?
UPDATE 2: I have found a couple of issues in the html format of the languages that were working! after properly formatting them, now all languages are behaving the same, with stripped out html. Basically, the languages that seemed to be working were not using the OTA update, and now they use it the HTML is gone.

Please help! I have spent 3 days already trying to debug the lib with no source code and checking all keys and languages to find the issue...

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

Hi @theSoenke can you help us out here? thanks!

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

Hello @theSoenke ... not sure if you have any news here... thanks!

from phrase-android.

DarkMinstrel avatar DarkMinstrel commented on May 29, 2024

Hi @angelolloqui !
There are no html tags because you're using the getString() method.
As per documentation, getString() strips all styling information and returns the naked string.
If you want to get styled CharSequence, try using getText() instead.

Alternatively, if you need to combine placeholders and styles in the same string, you should HTML-escape it (<b> -> &lt;b>), replace placeholders, and finally convert it with Html.fromHtml(). Please see the official Android docs on this topic:
https://developer.android.com/guide/topics/resources/string-resource.html#StylingWithHTML

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

Hi @DarkMinstrel , thanks for answering but I probably did not explain myself correctly.

We do use Html.fromHtml() from the string to set it as styled string from HTML, that is not the problem.
The strings do not need to be escaped unless there is a conflict on the HTML itself with your xml, in which case you could use the CDATA tag too.

By the way, this all works perfectly when we do phrase pull. For example, this string gets escaped automatically by the running the command:

    <string name="auth_home_terms_and_conditions"><![CDATA[By registering you are accepting our <br><a href=\"%1$s\">terms of use</a> and <a href=\"%2$s\">privacy policies</a>]]></string>

Everything works as expected until OTA comes into play. From that moment the HTML is stripped out from this string too, which is properly escaped.

The usage of getText() is not a valid alternative since it requires implementation changes all around the app. This is clearly a bug in the OTA management since it only happens with it active.

EDIT: By the way, your suggestion gave me an idea that this bug might just be related to a wrong usage of CDATA during the OTA download, you might be right when you say it is not properly escaped when using OTA.

EDIT 2: Manual urlencoding the HTML is not practical because we have tons of strings with it but also a second platform (iOS) making use of the same strings, so I have doubts the solution would apply in both (most likely the html will be rendered as HTML in iOS if we encode it)

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

By the way @DarkMinstrel or @theSoenke, I see you are quite busy, because you took 21 days to answer a "is your fault", probably not dedicating 5min to check your code first (sorry if you are not working on phrase, it is not clear to me if the answer is coming from an individual or a phrase employee). Can you at least provide access to the source code so I could fork it, try to fix it and provide a PR? This way I could also add some extra functionality like reset the previous OTA content or #23.
I can understand you have no resources to check this now but for us this is a very important bug that needs fix or we will stop using Phrase and look for an alternative. These kind of libraries should be open to anyone, the strength of your product is the whole platform, the code in the sdk has little value without any of it.

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

Got it, let me try that... 🤞

from phrase-android.

angelolloqui avatar angelolloqui commented on May 29, 2024

Awesome!! thanks @DarkMinstrel !! that seemed to work perfectly!! I am closing the issue and keep this change under test. If I see any other side effect from activating this checkbox I will let you know by reopening!

from phrase-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.