Browse Source

Voting chart & email deobfuscation improvements

pull/61/merge
Ezerous 6 years ago
parent
commit
438ec31459
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/TopicTask.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/TopicTaskResult.java
  4. 11
      app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java

4
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -184,7 +184,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
});
holder.submitButton.setVisibility(View.VISIBLE);
// put a warning instead of a question
holder.question.setText("This topic contains a poll that is not supported in mthmmy");
holder.question.setText("This topic contains a poll that is not supported in mTHMMY");
return;
}
@ -788,6 +788,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
hidePollResultsButton = itemView.findViewById(R.id.show_poll_options_button);
errorTextview = itemView.findViewById(R.id.error_too_many_checked);
voteChart = itemView.findViewById(R.id.vote_chart);
voteChart.setScaleEnabled(false);
voteChart.setTouchEnabled(false);
}
}

6
app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/TopicTask.java

@ -77,14 +77,12 @@ public class TopicTask extends AsyncTask<String, Void, TopicTaskResult> {
//Finds topic title if missing
String topicTitle = topic.select("td[id=top_subject]").first().text();
if (topicTitle.contains("Topic:")) {
if (topicTitle.contains("Topic:"))
topicTitle = topicTitle.substring(topicTitle.indexOf("Topic:") + 7
, topicTitle.indexOf("(Read") - 2);
} else {
else
topicTitle = topicTitle.substring(topicTitle.indexOf("Θέμα:") + 6
, topicTitle.indexOf("(Αναγνώστηκε") - 2);
Timber.d("Parsed title: %s", topicTitle);
}
//Finds current page's index
int currentPageIndex = TopicParser.parseCurrentPageIndex(topic, language);

2
app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/TopicTaskResult.java

@ -37,7 +37,7 @@ public class TopicTaskResult {
private final String topicTreeAndMods;
private final String topicViewers;
public TopicTaskResult(TopicTask.ResultCode resultCode, String topicTitle,
TopicTaskResult(TopicTask.ResultCode resultCode, String topicTitle,
String replyPageUrl, ArrayList<TopicItem> newPostsList, int loadedPageTopicId,
int currentPageIndex, int pageCount, int focusedPostIndex, String topicTreeAndMods,
String topicViewers) {

11
app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ParseHelpers.java

@ -200,22 +200,27 @@ public class ParseHelpers {
*/
public static Document parse(String html){
Document document = Jsoup.parse(html);
deobfuscateElements(document.select("span.__cf_email__"), true);
deobfuscateElements(document.select("span.__cf_email__,a.__cf_email__"), true);
return document;
}
/**
* Use this method instead of parse() if you are targetting specific elements
* Use this method instead of parse() if you are targeting specific elements
*/
public static void deobfuscateElements(Elements elements, boolean found){
if(!found)
elements = elements.select("span.__cf_email__");
elements = elements.select("span.__cf_email__,a.__cf_email__");
for (Element obfuscatedElement : elements) {
String deobfuscatedEmail = deobfuscateEmail(obfuscatedElement.attr("data-cfemail"));
if(obfuscatedElement.is("span")){
Element parent = obfuscatedElement.parent();
if (parent.is("a")&&parent.attr("href").contains("email-protection"))
parent.attr("href", "mailto:"+deobfuscatedEmail);
}
else if (obfuscatedElement.attr("href").contains("email-protection"))
obfuscatedElement.attr("href", "mailto:"+deobfuscatedEmail);
obfuscatedElement.replaceWith(new TextNode(deobfuscatedEmail, ""));
}
}

Loading…
Cancel
Save