Browse Source

Quote fixes and code inspection

pull/24/head
Apostolos Fanakis 7 years ago
parent
commit
32ed2b1f9d
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java
  4. 233
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/Posting.java
  5. 87
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  6. 98
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  7. 4
      app/src/main/res/layout-v21/activity_topic_post_row.xml
  8. 72
      app/src/main/res/layout/activity_about.xml
  9. 4
      app/src/main/res/layout/activity_board_sub_board.xml
  10. 4
      app/src/main/res/layout/activity_board_topic.xml
  11. 4
      app/src/main/res/layout/activity_topic_post_row.xml
  12. 7
      app/src/main/res/layout/activity_topic_quick_reply_row.xml
  13. 13
      app/src/main/res/layout/fragment_forum_board_row.xml

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java

@ -125,7 +125,7 @@ public class ForumFragment extends BaseFragment {
});
CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext());
recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
linearLayoutManager.getOrientation());

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -99,7 +99,7 @@ public class RecentFragment extends BaseFragment {
recentAdapter = new RecentAdapter(getActivity(), topicSummaries, fragmentInteractionListener);
CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext());
recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
linearLayoutManager.getOrientation());

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java

@ -111,7 +111,7 @@ public class UnreadFragment extends BaseFragment {
});
CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext());
recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
linearLayoutManager.getOrientation());

233
app/src/main/java/gr/thmmy/mthmmy/activities/topic/Posting.java

@ -1,14 +1,9 @@
package gr.thmmy.mthmmy.activities.topic;
import android.util.Log;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import okhttp3.Response;
import timber.log.Timber;
@ -86,232 +81,4 @@ class Posting {
}
return REPLY_STATUS.SUCCESSFUL;
}
/**
* This is a fucked up method.. Just don't waste your time here unless you have suicidal
* tendencies.
*
* @param html the html string to be transformed to BBcode
* @return the BBcode string
*/
static String htmlToBBcode(String html) {
Log.d("Cancer", html);
Map<String, String> bbMap = new HashMap<>();
Map<String, String> smileysMap1 = new HashMap<>();
Map<String, String> smileysMap2 = new HashMap<>();
smileysMap1.put("Smiley", ":)");
smileysMap1.put("Wink", ";)");
smileysMap1.put("Cheesy", ":D");
smileysMap1.put("Grin", ";D");
smileysMap1.put("Angry", ">:(");
smileysMap1.put("Sad", ":(");
smileysMap1.put("Shocked", ":o");
smileysMap1.put("Cool", "8))");
smileysMap1.put("Huh", ":???:");
smileysMap1.put("Roll Eyes", "::)");
smileysMap1.put("Tongue", ":P");
smileysMap1.put("Embarrassed", ":-[");
smileysMap1.put("Lips Sealed", ":-X");
smileysMap1.put("Kiss", ":-*");
smileysMap1.put("Cry", ":'(");
smileysMap1.put("heart", "<3");
smileysMap1.put("kleidaria", "^locked^");
smileysMap1.put("roll_over", "^rollover^");
smileysMap1.put("redface", "^redface^");
smileysMap1.put("confused", "^confused^");
smileysMap1.put("innocent", "^innocent^");
smileysMap1.put("sleep", "^sleep^");
smileysMap1.put("lips_sealed", "^sealed^");
smileysMap1.put("cool", "^cool^");
smileysMap1.put("crazy", "^crazy^");
smileysMap1.put("mad", "^mad^");
smileysMap1.put("wav", "^wav^");
smileysMap1.put("BinkyBaby", "^binkybaby^");
smileysMap1.put("DontKnow", "^dontknow^");
smileysMap1.put("angry4", ":angry4:");
smileysMap1.put("angryAndHot", "^angryhot^");
smileysMap1.put("angry", "^angry^");
smileysMap1.put("bang_head", "^banghead^");
smileysMap1.put("CryBaby", "^crybaby^");
smileysMap1.put("Hello", "^hello^");
smileysMap1.put("jerk", "^jerk^");
smileysMap1.put("NoNo", "^nono^");
smileysMap1.put("NotWorthy", "^notworthy^");
smileysMap1.put("Off-topic", "^off-topic^");
smileysMap1.put("Puke", "^puke^");
smileysMap1.put("Shout", "^shout^");
smileysMap1.put("Slurp", "^slurp^");
smileysMap1.put("SuperConfused", "^superconfused^");
smileysMap1.put("SuperInnocent", "^superinnocent^");
smileysMap1.put("CellPhone", "^cellPhone^");
smileysMap1.put("Idiot", "^idiot^");
smileysMap1.put("Knuppel", "^knuppel^");
smileysMap1.put("TickedOff", "^tickedOff^");
smileysMap1.put("Peace", "^peace^");
smileysMap1.put("Suspicious", "^suspicious^");
smileysMap1.put("Caffine", "^caffine^");
smileysMap1.put("argue", "^argue^");
smileysMap1.put("banned2", "^banned2^");
smileysMap1.put("banned", "^banned^");
smileysMap1.put("bath", "^bath^");
smileysMap1.put("beg", "^beg^");
smileysMap1.put("bluescreen", "^bluescreen^");
smileysMap1.put("boil", "^boil^");
smileysMap1.put("bye", "^bye^");
smileysMap1.put("callmerip", "^callmerip^");
smileysMap1.put("carnaval", "^carnaval^");
smileysMap1.put("clap", "^clap^");
smileysMap1.put("coffepot", "^coffepot^");
smileysMap1.put("crap", "^crap^");
smileysMap1.put("curses", "^curses^");
smileysMap1.put("funny", "^funny^");
smileysMap1.put("guitar", "^guitar^");
smileysMap1.put("kissy", "^kissy^");
smileysMap1.put("band", "^band^");
smileysMap1.put("ivres", "^ivres^");
smileysMap1.put("kaloe", "^kaloe^");
smileysMap1.put("kremala", "^kremala^");
smileysMap1.put("moon", "^moon^");
smileysMap1.put("mopping", "^mopping^");
smileysMap1.put("mountza", "^mountza^");
smileysMap1.put("pcsleep", "^pcsleep^");
smileysMap1.put("pinokio", "^pinokio^");
smileysMap1.put("poke", "^poke^");
smileysMap1.put("seestars", "^seestars^");
smileysMap1.put("sfyri", "^sfyri^");
smileysMap1.put("spam", "^spam^");
smileysMap1.put("super", "^super^");
smileysMap1.put("tafos", "^tafos^");
smileysMap1.put("tomato", "^tomato^");
smileysMap1.put("ytold", "^ytold^");
smileysMap1.put("beer", "^beer^");
smileysMap1.put("ο fritz!!!", "^fritz^");
smileysMap1.put("o Wade!!!", "^wade^");
smileysMap1.put("bonjour", "^hat^");
smileysMap1.put("bonjour2", "^miss^");
smileysMap1.put("question", "^que^");
smileysMap1.put("shifty", "^shifty^");
smileysMap1.put("shy", "^shy^");
smileysMap1.put("music_listenning", "^music_listen^");
smileysMap1.put("bag_face", "^bagface^");
smileysMap1.put("rotation", "^rotate^");
smileysMap1.put("love", "^love^");
smileysMap1.put("speech", "^speech^");
smileysMap1.put("shocked", "^shocked^");
smileysMap1.put("extremely_shocked", "^ex_shocked^");
smileysMap1.put("smurf", "^smurf^");
smileysMap1.put("monster", "^monster^");
smileysMap1.put("pig", "^pig^");
smileysMap1.put("lol", "^lol^");
smileysMap2.put("Police", "^Police^");
smileysMap2.put("foyska", "^fouska^");
smileysMap2.put("nista", "^nysta^");
smileysMap2.put("10_7_3", "^sfinaki^");
smileysMap2.put("yu", "^yue^");
smileysMap2.put("a-eatpaper", "^eatpaper^");
smileysMap2.put("lypi", "^lypi^");
smileysMap2.put("megashok1wq", "^aytoxeir^");
smileysMap2.put("victory", "^victory^");
smileysMap2.put("filarakia", "^filarakia^");
smileysMap2.put("rofl", "^rolfmao^");
smileysMap2.put("locked", "^lock^");
smileysMap2.put("facepalm", "^facepalm^");
//html stuff on the beginning
bbMap.put("<link rel=.+\">\n ", "");
//quotes and code headers
bbMap.put("\\s*?<div class=\"quoteheader\">(.*?(\\n))*?.*?<\\/div>", "");
bbMap.put("\\s*?<div class=\"codeheader\">(.*?(\\n))+?.*?<\\/div>", "");
bbMap.put("\\s*?<div class=\"quote\">(.*?(\\n))+?.*?<\\/div>", "");
bbMap.put("<br>", "\\\n");
//Non-breaking space
bbMap.put("&nbsp;", " ");
//bold
bbMap.put("\\s*?<b>([\\S\\s]+?)<\\/b>", "\\[b\\]$1\\[/b\\]");
//italics
bbMap.put("\\s*?<i>([\\S\\s]+?)<\\/i>", "\\[i\\]$1\\[/i\\]");
//underline
bbMap.put("\\s*?<span style=\"text-decoration: underline;\">([\\S\\s]+?)<\\/span>", "\\[u\\]$1\\[/u\\]");
//deleted
bbMap.put("\\s*?<del>([\\S\\s]+?)<\\/del>", "\\[s\\]$1\\[/s\\]");
//text color
bbMap.put("\\s*?<span style=\"color: (.+?);\">([\\S\\s]+?)<\\/span>", "\\[color=$1\\]$2\\[/color\\]");
//glow
bbMap.put("\\s*?<span style=\"background-color: (.+?);\">([\\S\\s]+?)<\\/span>", "\\[glow=$1,2,300\\]$2\\[/glow\\]");
//shadow
bbMap.put("\\s*?<span style=\"text-shadow: (.+?) (.+?)\">([\\S\\s]+?)<\\/span>", "\\[shadow=$1,$2\\]$3\\[/shadow\\]");
//running text
bbMap.put("\\s*?<marquee>\n ([\\S\\s]+?)\n <\\/marquee>", "\\[move\\]$1\\[/move\\]");
//alignment
bbMap.put("\\s*?<div align=\"center\">\n ([\\S\\s]+?)\n <\\/div>", "\\[center\\]$1\\[/center\\]");
bbMap.put("\\s*?<div style=\"text-align: (.+?);\">\n ([\\S\\s]+?)\n <\\/div>", "\\[$1\\]$2\\[/$1\\]");
//preformated
bbMap.put("\\s*?<pre>([\\S\\s]+?)<\\/pre>", "\\[pre\\]$1\\[/pre\\]");
//horizontal rule
bbMap.put("\\s*?<hr>", "\\[hr\\]");
//resize
bbMap.put("\\s*?<span style=\"font-size: (.+?);(.+?)\">([\\S\\s]+?)<\\/span>", "\\[size=$1\\]$3\\[/size\\]");
//font
bbMap.put("\\s*?<span style=\"font-family: (.+?);\">([\\S\\s]+?)<\\/span>", "\\[font=$1\\]$2\\[/font\\]");
//lists
bbMap.put("\\s+<li>(.+?)<\\/li>", "\\[li\\]$1\\[/li\\]");
bbMap.put("\n\\s+<ul style=\"margin-top: 0; margin-bottom: 0;\">([\\S\\s]+?)\n\\s+<\\/ul>",
"\\[list\\]\n$1\n\\[/list\\]");
//latex code
bbMap.put("\\s*?<img src=\".+?eq=([\\S\\s]+?)\" .+?\">", "\\[tex\\]$1\\[/tex\\]");
//code
bbMap.put("\\s*?<div class=\"code\">((.*?(\\n))+?.*?)<\\/div>", "\\[code\\]$1\\[/code\\]");
//teletype
bbMap.put("\\s*?<tt>([\\S\\s]+?)<\\/tt>", "\\[tt\\]$1\\[/tt\\]");
//superscript/subscript
bbMap.put("\\s*?<sub>([\\S\\s]+?)<\\/sub>", "\\[sub\\]$1\\[/sub\\]");
bbMap.put("\\s*?<sup>([\\S\\s]+?)<\\/sup>", "\\[sup\\]$1\\[/sup\\]");
//tables
bbMap.put("\\s*?<td.+?>([\\S\\s]+?)<\\/td>", "\\[td\\]$1\\[/td\\]");
bbMap.put("<tr>([\\S\\s]+?)\n <\\/tr>", "\\[tr\\]$1\\[/tr\\]");
bbMap.put("\\s*?<table style=\"(.+?)\">\n <tbody>\n ([\\S\\s]+?)\n <\\/tbody>\n <\\/table>"
, "\\[table\\]$2\\[/table\\]");
//videos
bbMap.put("\\s*?<div class=\"yt\">.+?watch\\?v=(.+?)\"((.|\\n)*?)/div>\n",
"[youtube]https://www.youtube.com/watch?v=$1[/youtube]");
//ftp
bbMap.put("<a href=\"ftp:(.+?)\" .+?>([\\S\\s]+?)<\\/a>", "\\[fpt=ftp:$1\\]$2\\[/ftp\\]");
//mailto
bbMap.put("\\s*?<a href=\"mailto:(.+?)\">([\\S\\s]+?)<\\/a>", "\\[email\\]$2\\[/email\\]");
//links
bbMap.put("\\s*?<a href=\"(.+?)\" .+?>([\\S\\s]+?)</a>", "\\[url=$1\\]$2\\[/url\\]");
//smileys
for (Map.Entry entry : smileysMap1.entrySet()) {
bbMap.put("\n <img src=\"(.+?)//www.thmmy.gr/smf/Smileys/default_dither/(.+?) alt=\""
+ entry.getKey().toString() + "\" .+?\">", entry.getValue().toString());
}
for (Map.Entry entry : smileysMap2.entrySet()) { //Those that have empty alt tag
bbMap.put("\n <img src=\"(.+?)//www.thmmy.gr/smf/Smileys/default_dither/"
+ entry.getKey().toString() + ".gif\" .+?\">", entry.getValue().toString());
}
bbMap.put("\n <img src=\"(.+?)//www.thmmy.gr/smf/Smileys/default_dither/undecided.gif\" alt=\"Undecided\" border=\"0\">"
, Matcher.quoteReplacement(":-\\"));
//html stuff on the end
bbMap.put("\n</div>", "");
for (Map.Entry entry : bbMap.entrySet()) {
html = html.replaceAll(entry.getKey().toString(), entry.getValue().toString());
}
//img need to be done last or it messes up everything else
html = html.replaceAll("\\s+<img src=\"(.+?)\" .+? width=\"(.+?)\" .+? height=\"(.+?)\" .+?>",
"\\[img width=$2 height=$3\\]$1\\[/img\\]");
html = html.replaceAll("\\s+<img src=\"(.+?)\" .+? height=\"(.+?)\" .+? width=\"(.+?)\" .+?>",
"\\[img height=$2 width=$3\\]$1\\[/img\\]");
html = html.replaceAll("\\s+<img src=\"(.+?)\" .+? width=\"(.+?)\" .+?>", "\\[img width=$2\\]$1\\[/img\\]");
html = html.replaceAll("\\s+<img src=\"(.+?)\" .+? height=\"(.+?)\" .+?>", "\\[img height=$2\\]$1\\[/img\\]");
html = html.replaceAll("\\s+<img src=\"(.+?)\".+?>", "\\[img\\]$1\\[/img\\]");
Log.d("Cancer", html);
return html;
}
}

87
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -237,6 +237,7 @@ public class TopicActivity extends BaseActivity {
new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.performClick();
return topicTask != null && topicTask.getStatus() == AsyncTask.Status.RUNNING;
}
}
@ -257,12 +258,8 @@ public class TopicActivity extends BaseActivity {
@Override
public void onClick(View view) {
if (sessionManager.isLoggedIn()) {
postsList.add(null);
topicAdapter.notifyItemInserted(postsList.size());
topicAdapter.prepareForReply(new ReplyTask(), topicTitle, loadedPageUrl);
replyFAB.hide();
bottomNavBar.setVisibility(View.GONE);
recyclerView.scrollToPosition(postsList.size() - 1);
PrepareForReply prepareForReply = new PrepareForReply();
prepareForReply.execute(topicAdapter.getToQuoteList());
}
}
});
@ -772,23 +769,25 @@ public class TopicActivity extends BaseActivity {
}
}
class ReplyTask extends AsyncTask<String, Void, Boolean> {
class PrepareForReply extends AsyncTask<ArrayList<Integer>, Void, Boolean> {
String numReplies, seqnum, sc, topic, buildedQuotes = "";
@Override
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
paginationEnabled(false);
replyFAB.setEnabled(false);
replyFAB.hide();
bottomNavBar.setVisibility(View.GONE);
}
@Override
protected Boolean doInBackground(String... message) {
protected Boolean doInBackground(ArrayList<Integer>... quoteList) {
Document document;
String numReplies, seqnum, sc, topic;
Request request = new Request.Builder()
.url(replyPageUrl + ";wap2")
.build();
try {
Response response = client.newCall(request).execute();
document = Jsoup.parse(response.body().string());
@ -797,22 +796,70 @@ public class TopicActivity extends BaseActivity {
seqnum = document.select("input[name=seqnum]").first().attr("value");
sc = document.select("input[name=sc]").first().attr("value");
topic = document.select("input[name=topic]").first().attr("value");
} catch (IOException e) {
Timber.e(e, "Post failed.");
} catch (IOException | Selector.SelectorParseException e) {
Timber.e(e, "Prepare failed.");
return false;
} catch (Selector.SelectorParseException e) {
Timber.e(e, "Post failed.");
}
for (Integer quotePosition : quoteList[0]) {
request = new Request.Builder()
.url("https://www.thmmy.gr/smf/index.php?action=quotefast;quote=" +
postsList.get(quotePosition).getPostIndex() +
";" + "sesc=" + sc + ";xml")
.build();
try {
Response response = client.newCall(request).execute();
document = Jsoup.parse(response.body().string());
String html = document.outerHtml();
if (Build.VERSION.SDK_INT >= 24) {
buildedQuotes += Html.fromHtml(
html.substring(html.indexOf("<quote>"), html.indexOf("</quote>")),
Html.FROM_HTML_MODE_LEGACY).toString();
} else {
buildedQuotes += Html.fromHtml(
html.substring(html.indexOf("<quote>"), html.indexOf("</quote>")))
.toString();
}
buildedQuotes += "\n\n";
} catch (IOException | Selector.SelectorParseException e) {
Timber.e(e, "Quote building failed.");
return false;
}
}
return true;
}
@Override
protected void onPostExecute(Boolean result) {
postsList.add(null);
topicAdapter.notifyItemInserted(postsList.size());
topicAdapter.prepareForReply(new ReplyTask(), topicTitle, numReplies, seqnum, sc,
topic, buildedQuotes);
recyclerView.scrollToPosition(postsList.size() - 1);
progressBar.setVisibility(ProgressBar.GONE);
}
}
class ReplyTask extends AsyncTask<String, Void, Boolean> {
@Override
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
paginationEnabled(false);
replyFAB.setEnabled(false);
}
@Override
protected Boolean doInBackground(String... args) {
RequestBody postBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("message", message[1])
.addFormDataPart("num_replies", numReplies)
.addFormDataPart("seqnum", seqnum)
.addFormDataPart("sc", sc)
.addFormDataPart("subject", message[0])
.addFormDataPart("topic", topic)
.addFormDataPart("message", args[1])
.addFormDataPart("num_replies", args[2])
.addFormDataPart("seqnum", args[3])
.addFormDataPart("sc", args[4])
.addFormDataPart("subject", args[0])
.addFormDataPart("topic", args[5])
.build();
Request post = new Request.Builder()

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

@ -10,10 +10,8 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.widget.AppCompatImageButton;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
@ -26,7 +24,6 @@ import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -35,14 +32,8 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import gr.thmmy.mthmmy.R;
@ -61,7 +52,6 @@ import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL;
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL;
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL;
import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME;
import static gr.thmmy.mthmmy.activities.topic.Posting.htmlToBBcode;
import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_WHITE;
import static gr.thmmy.mthmmy.activities.topic.TopicParser.USER_COLOR_YELLOW;
import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager;
@ -100,7 +90,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final String[] replyDataHolder = new String[2];
private final int replySubject = 0, replyText = 1;
private String loadedPageUrl = "";
private String numReplies, seqnum, sc, topic, buildedQuotes;
private boolean canReply = false;
/**
@ -119,10 +109,19 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.topicTask = topicTask;
}
void prepareForReply(TopicActivity.ReplyTask replyTask, String topicTitle, String loadedPageUrl) {
ArrayList<Integer> getToQuoteList(){
return toQuoteList;
}
void prepareForReply(TopicActivity.ReplyTask replyTask, String topicTitle, String numReplies,
String seqnum, String sc, String topic, String buildedQuotes) {
this.replyTask = replyTask;
this.topicTitle = topicTitle;
this.loadedPageUrl = loadedPageUrl;
this.numReplies = numReplies;
this.seqnum = seqnum;
this.sc = sc;
this.topic = topic;
this.buildedQuotes = buildedQuotes;
}
@Override
@ -160,12 +159,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//Default post subject
replyDataHolder[replySubject] = "Re: " + topicTitle;
//Build quotes
String quotes = "";
for (int quotePosition : toQuoteList) {
quotes += buildQuote(quotePosition);
}
if (!Objects.equals(quotes, ""))
replyDataHolder[replyText] = htmlToBBcode(quotes);
if (!Objects.equals(buildedQuotes, ""))
replyDataHolder[replyText] = buildedQuotes;
return new QuickReplyViewHolder(view, new CustomEditTextListener(replySubject),
new CustomEditTextListener(replyText));
}
@ -467,7 +462,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (holder.quickReply.getText().toString().isEmpty()) return;
holder.submitButton.setEnabled(false);
replyTask.execute(holder.quickReplySubject.getText().toString(),
holder.quickReply.getText().toString());
holder.quickReply.getText().toString(), numReplies, seqnum, sc, topic);
holder.quickReplySubject.getText().clear();
holder.quickReplySubject.setText("Re: " + topicTitle);
@ -497,9 +492,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
* Custom {@link RecyclerView.ViewHolder} implementation
*/
private class PostViewHolder extends RecyclerView.ViewHolder {
final CardView cardView;
final LinearLayout cardChildLinear;
final FrameLayout postDateAndNumber;
final TextView postDate, postNum, username, subject;
final ImageView thumbnail;
final public WebView post;
@ -515,9 +508,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
super(view);
//Initializes layout's graphic elements
//Standard stuff
cardView = view.findViewById(R.id.card_view);
cardChildLinear = view.findViewById(R.id.card_child_linear);
postDateAndNumber = view.findViewById(R.id.post_date_and_number_exp);
postDate = view.findViewById(R.id.post_date);
postNum = view.findViewById(R.id.post_number);
thumbnail = view.findViewById(R.id.thumbnail);
@ -549,7 +540,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final TextView username;
final EditText quickReply, quickReplySubject;
final AppCompatImageButton submitButton;
final CustomEditTextListener replySubject, replyText;
QuickReplyViewHolder(View quickReply, CustomEditTextListener replySubject
, CustomEditTextListener replyText) {
@ -557,10 +547,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
thumbnail = quickReply.findViewById(R.id.thumbnail);
username = quickReply.findViewById(R.id.username);
this.quickReply = quickReply.findViewById(R.id.quick_reply_text);
this.replyText = replyText;
this.quickReply.addTextChangedListener(replyText);
quickReplySubject = quickReply.findViewById(R.id.quick_reply_subject);
this.replySubject = replySubject;
quickReplySubject.addTextChangedListener(replySubject);
submitButton = quickReply.findViewById(R.id.quick_reply_submit);
}
@ -665,62 +653,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}
}
@Nullable
private String buildQuote(int quotePosition) {
Date postDate = null;
{
String date = postsList.get(quotePosition).getPostDate();
if (date != null) {
DateFormat format = new SimpleDateFormat("MMMM d, yyyy, h:m:s a", Locale.ENGLISH);
date = date.replace("Ιανουαρίου", "January");
date = date.replace("Φεβρουαρίου", "February");
date = date.replace("Μαρτίου", "March");
date = date.replace("Απριλίου", "April");
date = date.replace("Μαΐου", "May");
date = date.replace("Ιουνίου", "June");
date = date.replace("Ιουλίου", "July");
date = date.replace("Αυγούστου", "August");
date = date.replace("Σεπτεμβρίου", "September");
date = date.replace("Οκτωβρίου", "October");
date = date.replace("Νοεμβρίου", "November");
date = date.replace("Δεκεμβρίου", "December");
if (date.contains("Today")) {
date = date.replace("Today at",
Calendar.getInstance().getDisplayName(Calendar.MONTH,
Calendar.LONG, Locale.ENGLISH)
+ " " + Calendar.getInstance().get(Calendar.DAY_OF_MONTH)
+ ", " + Calendar.getInstance().get(Calendar.YEAR) + ",");
} else if (date.contains("Σήμερα")) {
date = date.replace("Σήμερα στις",
Calendar.getInstance().getDisplayName(Calendar.MONTH,
Calendar.LONG, Locale.ENGLISH)
+ " " + Calendar.getInstance().get(Calendar.DAY_OF_MONTH)
+ ", " + Calendar.getInstance().get(Calendar.YEAR) + ",");
if (date.contains("πμ")) date = date.replace("πμ", "am");
if (date.contains("μμ")) date = date.replace("μμ", "pm");
}
try {
postDate = format.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
if (postsList.get(quotePosition).getPostIndex() != 0) {
if (postDate != null) {
return "[quote author=" + postsList.get(quotePosition).getAuthor()
+ " link=topic=" + ThmmyPage.getTopicId(loadedPageUrl) + ".msg"
+ postsList.get(quotePosition).getPostIndex()
+ "#msg" + postsList.get(quotePosition).getPostIndex()
+ " date=" + postDate.getTime() / 1000 + "]"
+ "\n" + postsList.get(quotePosition).getContent()
+ "\n" + "[/quote]" + "\n\n";
}
}
return null;
}
/**
* Returns a String with a single FontAwesome typeface character corresponding to this file's
* extension.

4
app/src/main/res/layout-v21/activity_topic_post_row.xml

@ -37,6 +37,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
@ -94,6 +95,7 @@
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_quote_button"
android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" />
</LinearLayout>
@ -102,6 +104,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
@ -212,6 +215,7 @@
android:layout_marginRight="16dp"
android:background="@color/card_background"
android:clickable="true"
android:focusable="true"
android:text="@string/post" />
</FrameLayout>

72
app/src/main/res/layout/activity_about.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
@ -21,8 +20,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>
app:popupTheme="@style/ToolbarTheme"></android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
@ -30,11 +28,10 @@
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@color/background">
android:background="@color/background"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -51,11 +48,10 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:contentDescription="@string/logo"
android:src="@drawable/logo_animated"
/>
android:src="@drawable/logo_animated" />
<TextView
@ -65,6 +61,7 @@
android:layout_below="@+id/logoView"
android:layout_centerHorizontal="true"
android:clickable="true"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/accent"
android:textStyle="italic" />
@ -73,65 +70,65 @@
android:id="@+id/open_source_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/version"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/open_source"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/accent"
android:layout_below="@+id/version"
android:layout_alignParentStart="true"
android:textStyle="bold" />
<TextView
android:id="@+id/open_source_text"
android:layout_below="@+id/open_source_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/open_source_header"
android:autoLink="web"
android:text="@string/open_source_text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/iron"
android:layout_alignParentStart="true" />
android:textColor="@color/iron" />
<TextView
android:id="@+id/libraries_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/open_source_text"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/libraries"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/accent"
android:layout_below="@+id/open_source_text"
android:layout_alignParentStart="true"
android:textStyle="bold" />
<TextView
android:id="@+id/libraries_text"
android:layout_below="@+id/libraries_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/libraries_header"
android:text="@string/libraries_text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/iron"
android:layout_alignParentStart="true" />
android:textColor="@color/iron" />
<TextView
android:layout_below="@+id/libraries_text"
android:onClick="displayApacheLibraries"
android:id="@+id/apache_libs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/apache_v2_0_libraries"
android:id="@+id/apache_libs"
android:layout_alignParentStart="true"
android:layout_below="@+id/libraries_text"
android:onClick="displayApacheLibraries"
android:text="@string/apache_v2_0_libraries"
android:textColor="@color/accent" />
<TextView
android:id="@+id/mit_libs"
android:onClick="displayMITLibraries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/the_mit_libraries"
android:layout_below="@+id/apache_libs"
android:layout_alignParentStart="true"
android:layout_below="@+id/apache_libs"
android:onClick="displayMITLibraries"
android:text="@string/the_mit_libraries"
android:textColor="@color/accent" />
@ -139,24 +136,24 @@
android:id="@+id/contact_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/mit_libs"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/contact"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/accent"
android:layout_below="@+id/mit_libs"
android:layout_alignParentStart="true"
android:textStyle="bold" />
<TextView
android:id="@+id/contact_text"
android:layout_below="@+id/contact_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/contact_header"
android:autoLink="email|web"
android:text="@string/contact_text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/iron"
android:layout_alignParentStart="true" />
android:textColor="@color/iron" />
</RelativeLayout>
</ScrollView>
@ -175,7 +172,6 @@
android:layout_gravity="center"
android:contentDescription="@string/trollPic"
android:foregroundGravity="center"
android:src="@drawable/fun"
/>
android:src="@drawable/fun" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

4
app/src/main/res/layout/activity_board_sub_board.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
@ -80,6 +79,7 @@
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:focusable="true"
android:text="@string/child_board_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp" />

4
app/src/main/res/layout/activity_board_topic.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topic_row_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -73,6 +72,7 @@
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:focusable="true"
android:text="@string/topic_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp" />

4
app/src/main/res/layout/activity_topic_post_row.xml

@ -37,6 +37,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
@ -93,6 +94,7 @@
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_quote_button"
android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" />
</LinearLayout>
@ -101,6 +103,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
@ -211,6 +214,7 @@
android:layout_marginRight="16dp"
android:background="@color/card_background"
android:clickable="true"
android:focusable="true"
android:text="@string/post" />
</FrameLayout>

7
app/src/main/res/layout/activity_topic_quick_reply_row.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -8,8 +7,7 @@
android:paddingEnd="4dp"
android:paddingStart="4dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -32,6 +30,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">

13
app/src/main/res/layout/fragment_forum_board_row.xml

@ -2,19 +2,20 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/primary_lighter">
android:background="@color/primary_lighter"
android:orientation="vertical">
<TextView
android:id="@+id/board"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/accent"
android:textSize="16sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_horizontal"
android:padding="8dp"/>
android:padding="8dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/accent"
android:textSize="16sp" />
</LinearLayout>
Loading…
Cancel
Save