Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/src/main/java/fr/gaulupeau/apps/Poche/network/Updater.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fr.gaulupeau.apps.Poche.network;

import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;

Expand Down Expand Up @@ -223,7 +225,7 @@ private long performUpdate(ArticlesChangedEvent event, boolean full,

article = new Article(null);
article.setArticleId(id);
article.setTitle(apiArticle.title);
article.setTitle(unescapeHtml(apiArticle.title));
article.setArticleContent(new ArticleContent(null, apiArticle.content));
article.setDomain(apiArticle.domainName);
article.setUrl(apiArticle.url);
Expand Down Expand Up @@ -251,8 +253,8 @@ private long performUpdate(ArticlesChangedEvent event, boolean full,
articleContentToUpdate.add(article.getArticleContent());
articleChanges.add(ChangeType.CONTENT_CHANGED);
}
if(!equalOrEmpty(article.getTitle(), apiArticle.title)) {
article.setTitle(apiArticle.title);
if(!equalOrEmpty(article.getTitle(), unescapeHtml(apiArticle.title))) {
article.setTitle(unescapeHtml(apiArticle.title));
articleChanges.add(ChangeType.TITLE_CHANGED);
}
if(!equalOrEmpty(article.getDomain(), apiArticle.domainName)) {
Expand Down Expand Up @@ -552,6 +554,14 @@ private boolean equalOrEmpty(CharSequence s1, CharSequence s2) {
|| TextUtils.equals(s1, s2);
}

private String unescapeHtml(String s) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY).toString();
} else {
return Html.fromHtml(s).toString();
}
}

private void fixArticleNullValues(Article article) {
if(article.getTitle() == null) article.setTitle("");
if(article.isArticleContentLoaded() && article.getContent() == null) {
Expand Down