diff --git a/app/build.gradle b/app/build.gradle index 522c3627..c7dc1920 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,8 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { - def date = new Date().format('ddMMyy_HHmm'); + //def date = new Date().format('ddMMyy_HHmm'); + def date = 1; archivesBaseName = archivesBaseName + "-$date" } } @@ -28,11 +29,11 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.2.0' - compile 'com.android.support:design:25.2.0' - compile 'com.android.support:support-v4:25.2.0' - compile 'com.android.support:cardview-v7:25.2.0' - compile 'com.android.support:recyclerview-v7:25.2.0' + compile 'com.android.support:appcompat-v7:25.3.0' + compile 'com.android.support:design:25.3.0' + compile 'com.android.support:support-v4:25.3.0' + compile 'com.android.support:cardview-v7:25.3.0' + compile 'com.android.support:recyclerview-v7:25.3.0' compile 'com.google.firebase:firebase-crash:10.2.0' compile 'com.squareup.okhttp3:okhttp:3.6.0' compile 'com.squareup.picasso:picasso:2.5.2' 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 3f5154fb..6f1d438c 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 @@ -42,9 +42,12 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; +import java.util.regex.Matcher; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.board.BoardActivity; @@ -149,7 +152,7 @@ class TopicAdapter extends RecyclerView.Adapter { quotes += buildQuote(quotePosition); } if (!Objects.equals(quotes, "")) - replyDataHolder[replyText] = quotes; + replyDataHolder[replyText] = htmlToBBcode(quotes); return new QuickReplyViewHolder(view, new CustomEditTextListener(replySubject), new CustomEditTextListener(replyText)); } @@ -779,6 +782,222 @@ class TopicAdapter extends RecyclerView.Adapter { return null; } + private String htmlToBBcode(String 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("\n\\s+?
\n (.+?)\n
", ""); + bbMap.put("\n\\s+?
\n (.+?)\n
", ""); + bbMap.put("\n\\s+?
\n (.+?)\n
", ""); + bbMap.put("
", "\n"); + //bold + bbMap.put("\n\\s+?(.+?)", "\\[b\\]$1\\[/b\\]"); + //italics + bbMap.put("\n\\s+?(.+?)", "\\[i\\]$1\\[/i\\]"); + //underline + bbMap.put("\n\\s+?(.+?)", "\\[u\\]$1\\[/u\\]"); + //deleted + bbMap.put("\n\\s+?(.+?)", "\\[s\\]$1\\[/s\\]"); + //text color + bbMap.put("\n\\s+?(.+?)", "\\[color=$1\\]$2\\[/color\\]"); + //glow + bbMap.put("\n\\s+?(.+?)", "\\[glow=$1,2,300\\]$2\\[/glow\\]"); + //shadow + bbMap.put("\n\\s+?(.+?)", "\\[shadow=$1,$2\\]$3\\[/shadow\\]"); + //running text + bbMap.put("\\s+?\n (.+?)\n ", "\\[move\\]$1\\[/move\\]"); + //alignment + bbMap.put("\n\\s+?
\n (.+?)\n
", "\\[center\\]$1\\[/center\\]"); + bbMap.put("\n\\s+?
\n (.+?)\n
", "\\[$1\\]$2\\[/$1\\]"); + //preformated + bbMap.put("\n\\s+?
(.+?)
", "\\[pre\\]$1\\[/pre\\]"); + //horizontal rule + bbMap.put("\n\\s+?
", "\\[hr\\]"); + //resize + bbMap.put("\n\\s+?(.+?)", "\\[size=$1\\]$3\\[/size\\]"); + //font + bbMap.put("\n\\s+?(.+?)", "\\[font=$1\\]$2\\[/font\\]"); + //lists + bbMap.put("\\s+
  • (.+?)
  • ", "\\[li\\]$1\\[/li\\]"); + bbMap.put("\n\\s+
      ([\\S\\s]+?)\n\\s+
    ", + "\\[list\\]\n$1\n\\[/list\\]"); + //latex code + bbMap.put("\n\\s+?", "\\[tex\\]$1\\[/tex\\]"); + //code + bbMap.put("\n\\s+?
    \n (.+?)\n
    ", "\\[code\\]$1\\[/code\\]"); + //teletype + bbMap.put("\n\\s+?(.+?)", "\\[tt\\]$1\\[/tt\\]"); + //superscript/subscript + bbMap.put("\n\\s+?(.+?)", "\\[sub\\]$1\\[/sub\\]"); + bbMap.put("\n\\s+?(.+?)", "\\[sup\\]$1\\[/sup\\]"); + //tables + bbMap.put("\\s+?([\\S\\s]+?)", "\\[td\\]$1\\[/td\\]"); + bbMap.put("([\\S\\s]+?)\n ", "\\[tr\\]$1\\[/tr\\]"); + bbMap.put("\n\\s+?\n \n ([\\S\\s]+?)\n \n
    " + , "\\[table\\]$2\\[/table\\]"); + //videos + bbMap.put("\n\\s+?
    \n", + "[youtube]https://www.youtube.com/watch?v=$1[/youtube]"); + //ftp + bbMap.put("([\\S\\s]+?)", "\\[fpt=ftp:$1\\]$2\\[/ftp\\]"); + //mailto + bbMap.put("\n\\s+?([\\S\\s]+?)", "\\[email\\]$2\\[/email\\]"); + //links + bbMap.put("\n\\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\\]"); + + return html; + } + /** * Returns a String with a single FontAwesome typeface character corresponding to this file's * extension.