diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index 4adb199e..731d19fb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/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()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index ce940cd2..74a47d77 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/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()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index 5fec960f..8fbd42d1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/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()); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/Posting.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/Posting.java index 3fe99911..cc08f17d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/Posting.java +++ b/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 bbMap = new HashMap<>(); - Map smileysMap1 = new HashMap<>(); - Map 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("\n ", ""); - //quotes and code headers - bbMap.put("\\s*?
(.*?(\\n))*?.*?<\\/div>", ""); - bbMap.put("\\s*?
(.*?(\\n))+?.*?<\\/div>", ""); - bbMap.put("\\s*?
(.*?(\\n))+?.*?<\\/div>", ""); - bbMap.put("
", "\\\n"); - //Non-breaking space - bbMap.put(" ", " "); - //bold - bbMap.put("\\s*?([\\S\\s]+?)<\\/b>", "\\[b\\]$1\\[/b\\]"); - //italics - bbMap.put("\\s*?([\\S\\s]+?)<\\/i>", "\\[i\\]$1\\[/i\\]"); - //underline - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[u\\]$1\\[/u\\]"); - //deleted - bbMap.put("\\s*?([\\S\\s]+?)<\\/del>", "\\[s\\]$1\\[/s\\]"); - //text color - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[color=$1\\]$2\\[/color\\]"); - //glow - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[glow=$1,2,300\\]$2\\[/glow\\]"); - //shadow - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[shadow=$1,$2\\]$3\\[/shadow\\]"); - //running text - bbMap.put("\\s*?\n ([\\S\\s]+?)\n <\\/marquee>", "\\[move\\]$1\\[/move\\]"); - //alignment - bbMap.put("\\s*?
\n ([\\S\\s]+?)\n <\\/div>", "\\[center\\]$1\\[/center\\]"); - bbMap.put("\\s*?
\n ([\\S\\s]+?)\n <\\/div>", "\\[$1\\]$2\\[/$1\\]"); - //preformated - bbMap.put("\\s*?
([\\S\\s]+?)<\\/pre>", "\\[pre\\]$1\\[/pre\\]");
-        //horizontal rule
-        bbMap.put("\\s*?
", "\\[hr\\]"); - //resize - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[size=$1\\]$3\\[/size\\]"); - //font - bbMap.put("\\s*?([\\S\\s]+?)<\\/span>", "\\[font=$1\\]$2\\[/font\\]"); - //lists - bbMap.put("\\s+
  • (.+?)<\\/li>", "\\[li\\]$1\\[/li\\]"); - bbMap.put("\n\\s+
      ([\\S\\s]+?)\n\\s+<\\/ul>", - "\\[list\\]\n$1\n\\[/list\\]"); - //latex code - bbMap.put("\\s*?", "\\[tex\\]$1\\[/tex\\]"); - //code - bbMap.put("\\s*?
      ((.*?(\\n))+?.*?)<\\/div>", "\\[code\\]$1\\[/code\\]"); - //teletype - bbMap.put("\\s*?([\\S\\s]+?)<\\/tt>", "\\[tt\\]$1\\[/tt\\]"); - //superscript/subscript - bbMap.put("\\s*?([\\S\\s]+?)<\\/sub>", "\\[sub\\]$1\\[/sub\\]"); - bbMap.put("\\s*?([\\S\\s]+?)<\\/sup>", "\\[sup\\]$1\\[/sup\\]"); - //tables - bbMap.put("\\s*?([\\S\\s]+?)<\\/td>", "\\[td\\]$1\\[/td\\]"); - bbMap.put("([\\S\\s]+?)\n <\\/tr>", "\\[tr\\]$1\\[/tr\\]"); - bbMap.put("\\s*?\n \n ([\\S\\s]+?)\n <\\/tbody>\n <\\/table>" - , "\\[table\\]$2\\[/table\\]"); - //videos - bbMap.put("\\s*?
      .+?watch\\?v=(.+?)\"((.|\\n)*?)/div>\n", - "[youtube]https://www.youtube.com/watch?v=$1[/youtube]"); - //ftp - bbMap.put("([\\S\\s]+?)<\\/a>", "\\[fpt=ftp:$1\\]$2\\[/ftp\\]"); - //mailto - bbMap.put("\\s*?([\\S\\s]+?)<\\/a>", "\\[email\\]$2\\[/email\\]"); - //links - bbMap.put("\\s*?([\\S\\s]+?)", "\\[url=$1\\]$2\\[/url\\]"); - //smileys - for (Map.Entry entry : smileysMap1.entrySet()) { - bbMap.put("\n \""", entry.getValue().toString()); - } - for (Map.Entry entry : smileysMap2.entrySet()) { //Those that have empty alt tag - bbMap.put("\n ", entry.getValue().toString()); - } - - bbMap.put("\n \"Undecided\"" - , Matcher.quoteReplacement(":-\\")); - - //html stuff on the end - bbMap.put("\n
      ", ""); - - 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 width=$2 height=$3\\]$1\\[/img\\]"); - html = html.replaceAll("\\s+", - "\\[img height=$2 width=$3\\]$1\\[/img\\]"); - html = html.replaceAll("\\s+", "\\[img width=$2\\]$1\\[/img\\]"); - html = html.replaceAll("\\s+", "\\[img height=$2\\]$1\\[/img\\]"); - html = html.replaceAll("\\s+", "\\[img\\]$1\\[/img\\]"); - - Log.d("Cancer", html); - return html; - } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 8396a697..5c2e7107 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/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()); } } }); @@ -626,10 +623,10 @@ public class TopicActivity extends BaseActivity { invalidateOptionsMenu(); } - if (!(postsList.isEmpty() || postsList.size() == 0)){ + if (!(postsList.isEmpty() || postsList.size() == 0)) { recyclerView.getRecycledViewPool().clear(); //Avoid inconsistency detected bug postsList.clear(); - topicAdapter.notifyItemRangeRemoved(0, postsList.size()-1); + topicAdapter.notifyItemRangeRemoved(0, postsList.size() - 1); } postsList.addAll(localPostsList); topicAdapter.notifyItemRangeInserted(0, postsList.size()); @@ -772,23 +769,25 @@ public class TopicActivity extends BaseActivity { } } - class ReplyTask extends AsyncTask { + class PrepareForReply extends AsyncTask, 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... 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."); - return false; - } catch (Selector.SelectorParseException e) { - Timber.e(e, "Post failed."); + } catch (IOException | Selector.SelectorParseException e) { + Timber.e(e, "Prepare failed."); return false; } + 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(""), html.indexOf("")), + Html.FROM_HTML_MODE_LEGACY).toString(); + } else { + buildedQuotes += Html.fromHtml( + html.substring(html.indexOf(""), html.indexOf(""))) + .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 { + + @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() diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index d3d95796..d590354a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/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 { 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 { this.topicTask = topicTask; } - void prepareForReply(TopicActivity.ReplyTask replyTask, String topicTitle, String loadedPageUrl) { + ArrayList 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 { //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)); } @@ -311,7 +306,7 @@ class TopicAdapter extends RecyclerView.Adapter { holder.personalText.setVisibility(View.VISIBLE); } else holder.personalText.setVisibility(View.GONE); - if (mUserColor != USER_COLOR_YELLOW){ + if (mUserColor != USER_COLOR_YELLOW) { holder.username.setTextColor(mUserColor); } else { holder.username.setTextColor(USER_COLOR_WHITE); @@ -467,7 +462,7 @@ class TopicAdapter extends RecyclerView.Adapter { 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 { * 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 { 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 { 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 { 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 { } } - @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. diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index a4c6ee2d..de20aef3 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/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" /> @@ -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" /> diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 306d2b76..7d9a8461 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,6 +1,5 @@ - - + app:popupTheme="@style/ToolbarTheme"> @@ -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"> - + android:src="@drawable/logo_animated" /> + android:textStyle="italic" /> + android:textColor="@color/iron" /> + android:textColor="@color/iron" /> @@ -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" /> + android:textColor="@color/iron" /> @@ -175,7 +172,6 @@ android:layout_gravity="center" android:contentDescription="@string/trollPic" android:foregroundGravity="center" - android:src="@drawable/fun" - /> + android:src="@drawable/fun" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board_sub_board.xml b/app/src/main/res/layout/activity_board_sub_board.xml index 3b202022..6362e043 100644 --- a/app/src/main/res/layout/activity_board_sub_board.xml +++ b/app/src/main/res/layout/activity_board_sub_board.xml @@ -1,6 +1,5 @@ - + android:textSize="22sp" /> + android:src="@drawable/ic_arrow_drop_down" /> + android:textStyle="italic" /> + android:textSize="12sp" /> + android:textSize="12sp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board_topic.xml b/app/src/main/res/layout/activity_board_topic.xml index d041cc46..141f3876 100644 --- a/app/src/main/res/layout/activity_board_topic.xml +++ b/app/src/main/res/layout/activity_board_topic.xml @@ -1,6 +1,5 @@ - + android:textSize="18sp" /> + android:src="@drawable/ic_arrow_drop_down" /> + android:textSize="12sp" /> + android:textSize="12sp" /> + android:textSize="12sp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_post_row.xml b/app/src/main/res/layout/activity_topic_post_row.xml index 4581ac89..907f67d1 100644 --- a/app/src/main/res/layout/activity_topic_post_row.xml +++ b/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" /> @@ -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" /> diff --git a/app/src/main/res/layout/activity_topic_quick_reply_row.xml b/app/src/main/res/layout/activity_topic_quick_reply_row.xml index 870d0a8c..c77d3c07 100644 --- a/app/src/main/res/layout/activity_topic_quick_reply_row.xml +++ b/app/src/main/res/layout/activity_topic_quick_reply_row.xml @@ -1,6 +1,5 @@ - - @@ -53,7 +52,7 @@ android:contentDescription="@string/post_thumbnail" android:maxHeight="@dimen/thumbnail_size" android:maxWidth="@dimen/thumbnail_size" - android:src="@drawable/ic_default_user_thumbnail"/> + android:src="@drawable/ic_default_user_thumbnail" /> + android:textStyle="bold" /> + tools:ignore="SmallSp" /> + android:inputType="textMultiLine" /> + android:src="@drawable/ic_send" /> diff --git a/app/src/main/res/layout/fragment_forum_board_row.xml b/app/src/main/res/layout/fragment_forum_board_row.xml index 4fdace98..871c5450 100644 --- a/app/src/main/res/layout/fragment_forum_board_row.xml +++ b/app/src/main/res/layout/fragment_forum_board_row.xml @@ -2,19 +2,20 @@ + android:background="@color/primary_lighter" + android:orientation="vertical"> + android:padding="8dp" + android:textAppearance="?attr/textAppearanceListItem" + android:textColor="@color/accent" + android:textSize="16sp" /> \ No newline at end of file