diff --git a/twidere/build.gradle b/twidere/build.gradle index dbc0fef5a..7d7580504 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -227,6 +227,7 @@ dependencies { implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15' implementation 'com.sprylab.android.texturevideoview:texturevideoview:1.2.1' implementation 'com.squareup:pollexor:2.0.4' + implementation 'org.apache.commons:commons-lang3:3.10' implementation 'org.apache.commons:commons-text:1.8' implementation "org.apache.james:apache-mime4j-core:${libVersions['Mime4J']}" implementation "org.apache.james:apache-mime4j-storage:${libVersions['Mime4J']}" @@ -327,4 +328,4 @@ if (enableGoogleVariant) { // START Non-FOSS component apply plugin: 'com.google.gms.google-services' // END Non-FOSS component -} \ No newline at end of file +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/MessagesConversationAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/MessagesConversationAdapter.kt index 3f7792b87..ad90f2e6c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/MessagesConversationAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/MessagesConversationAdapter.kt @@ -27,6 +27,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.bumptech.glide.RequestManager +import org.apache.commons.lang3.time.DateUtils import org.mariotaku.chameleon.Chameleon import org.mariotaku.chameleon.ChameleonUtils import org.mariotaku.kpreferences.get @@ -39,7 +40,6 @@ import org.mariotaku.twidere.constant.linkHighlightOptionKey import org.mariotaku.twidere.constant.mediaPreviewStyleKey import org.mariotaku.twidere.constant.nameFirstKey import org.mariotaku.twidere.exception.UnsupportedCountIndexException -import org.mariotaku.twidere.extension.isSameDay import org.mariotaku.twidere.extension.model.timestamp import org.mariotaku.twidere.model.* import org.mariotaku.twidere.model.ParcelableMessage.MessageType @@ -137,7 +137,7 @@ class MessagesConversationAdapter( + itemCounts[ITEM_START_MESSAGE] - 1) { calendars.first.timeInMillis = getMessageTimestamp(position + 1) calendars.second.timeInMillis = message.timestamp - showDate = !calendars.first.isSameDay(calendars.second) + showDate = !DateUtils.isSameDay(calendars.first, calendars.second) } (holder as AbsMessageViewHolder).display(message, showDate) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt index 142cd7307..dae74fce7 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt @@ -1,18 +1,18 @@ /* * Twidere - Twitter client for Android - * + * * Copyright (C) 2012-2014 Mariotaku Lee - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -36,6 +36,7 @@ import androidx.multidex.MultiDex import com.bumptech.glide.Glide import nl.komponents.kovenant.task import okhttp3.Dns +import org.apache.commons.lang3.concurrent.ConcurrentUtils import org.mariotaku.abstask.library.TaskStarter import org.mariotaku.commons.logansquare.LoganSquareMapperFinder import org.mariotaku.kpreferences.KPreferences @@ -59,7 +60,6 @@ import org.mariotaku.twidere.extension.setLocale import org.mariotaku.twidere.model.DefaultFeatures import org.mariotaku.twidere.receiver.ConnectivityStateReceiver import org.mariotaku.twidere.util.* -import org.mariotaku.twidere.util.concurrent.ConstantFuture import org.mariotaku.twidere.util.content.TwidereSQLiteOpenHelper import org.mariotaku.twidere.util.dagger.ApplicationModule import org.mariotaku.twidere.util.dagger.GeneralComponent @@ -320,7 +320,7 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener { LoganSquareMapperFinder.setDefaultExecutor(object : LoganSquareMapperFinder.FutureExecutor { override fun submit(callable: Callable): Future { if (Looper.getMainLooper().isCurrentThreadCompat) { - return ConstantFuture(callable.call()) + return ConcurrentUtils.constantFuture(callable.call()) } return executor.submit(callable) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/CalendarExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/CalendarExtensions.kt deleted file mode 100644 index 6f5138f53..000000000 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/CalendarExtensions.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Twidere - Twitter client for Android - * - * Copyright (C) 2012-2017 Mariotaku Lee - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.mariotaku.twidere.extension - -import java.util.* - -/** - * Created by mariotaku on 2017/9/25. - */ -fun Calendar.isSameDay(that: Calendar): Boolean { - return this[Calendar.ERA] == that[Calendar.ERA] && - this[Calendar.YEAR] == that[Calendar.YEAR] && - this[Calendar.DAY_OF_YEAR] == that[Calendar.DAY_OF_YEAR] -} \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/api/StatusExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/api/StatusExtensions.kt index d16def41d..d399bef71 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/api/StatusExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/api/StatusExtensions.kt @@ -21,6 +21,7 @@ package org.mariotaku.twidere.extension.model.api import android.text.Spanned import android.text.style.URLSpan +import org.apache.commons.text.translate.EntityArrays import org.apache.commons.text.translate.LookupTranslator import org.mariotaku.commons.text.CodePointArray import org.mariotaku.ktextension.isNotNullOrEmpty @@ -40,7 +41,6 @@ import org.mariotaku.twidere.model.util.ParcelableLocationUtils import org.mariotaku.twidere.model.util.ParcelableMediaUtils import org.mariotaku.twidere.text.AcctMentionSpan import org.mariotaku.twidere.text.HashtagSpan -import org.mariotaku.twidere.util.EntityArrays import org.mariotaku.twidere.util.HtmlBuilder import org.mariotaku.twidere.util.HtmlSpanBuilder import org.mariotaku.twidere.util.InternalTwitterContentUtils @@ -421,4 +421,4 @@ class StatusTextWithIndices { var text: String? = null var spans: Array? = null var range: IntArray? = null -} \ No newline at end of file +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/EntityArrays.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/EntityArrays.kt deleted file mode 100644 index 97327a24f..000000000 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/EntityArrays.kt +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.mariotaku.twidere.util - -import java.util.* - -/** - * Class holding various entity data for HTML and XML - generally for use with - * the LookupTranslator. - * All Maps are generated using `java.util.Collections.unmodifiableMap()`. - * - * @since 1.0 - */ -object EntityArrays { - - /** - * A Map<CharSequence, CharSequence> to to escape - * [ISO-8859-1](https://secure.wikimedia.org/wikipedia/en/wiki/ISO/IEC_8859-1) - * characters to their named HTML 3.x equivalents. - */ - val ISO8859_1_ESCAPE: Map = mapOf( - "\u00A0" to " ", // non-breaking space - "\u00A1" to "¡", // inverted exclamation mark - "\u00A2" to "¢", // cent sign - "\u00A3" to "£", // pound sign - "\u00A4" to "¤", // currency sign - "\u00A5" to "¥", // yen sign = yuan sign - "\u00A6" to "¦", // broken bar = broken vertical bar - "\u00A7" to "§", // section sign - "\u00A8" to "¨", // diaeresis = spacing diaeresis - "\u00A9" to "©", // © - copyright sign - "\u00AA" to "ª", // feminine ordinal indicator - "\u00AB" to "«", // left-pointing double angle quotation mark = left pointing guillemet - "\u00AC" to "¬", // not sign - "\u00AD" to "­", // soft hyphen = discretionary hyphen - "\u00AE" to "®", // ® - registered trademark sign - "\u00AF" to "¯", // macron = spacing macron = overline = APL overbar - "\u00B0" to "°", // degree sign - "\u00B1" to "±", // plus-minus sign = plus-or-minus sign - "\u00B2" to "²", // superscript two = superscript digit two = squared - "\u00B3" to "³", // superscript three = superscript digit three = cubed - "\u00B4" to "´", // acute accent = spacing acute - "\u00B5" to "µ", // micro sign - "\u00B6" to "¶", // pilcrow sign = paragraph sign - "\u00B7" to "·", // middle dot = Georgian comma = Greek middle dot - "\u00B8" to "¸", // cedilla = spacing cedilla - "\u00B9" to "¹", // superscript one = superscript digit one - "\u00BA" to "º", // masculine ordinal indicator - "\u00BB" to "»", // right-pointing double angle quotation mark = right pointing guillemet - "\u00BC" to "¼", // vulgar fraction one quarter = fraction one quarter - "\u00BD" to "½", // vulgar fraction one half = fraction one half - "\u00BE" to "¾", // vulgar fraction three quarters = fraction three quarters - "\u00BF" to "¿", // inverted question mark = turned question mark - "\u00C0" to "À", // À - uppercase A, grave accent - "\u00C1" to "Á", // Á - uppercase A, acute accent - "\u00C2" to "Â", //  - uppercase A, circumflex accent - "\u00C3" to "Ã", // à - uppercase A, tilde - "\u00C4" to "Ä", // Ä - uppercase A, umlaut - "\u00C5" to "Å", // Å - uppercase A, ring - "\u00C6" to "Æ", // Æ - uppercase AE - "\u00C7" to "Ç", // Ç - uppercase C, cedilla - "\u00C8" to "È", // È - uppercase E, grave accent - "\u00C9" to "É", // É - uppercase E, acute accent - "\u00CA" to "Ê", // Ê - uppercase E, circumflex accent - "\u00CB" to "Ë", // Ë - uppercase E, umlaut - "\u00CC" to "Ì", // Ì - uppercase I, grave accent - "\u00CD" to "Í", // Í - uppercase I, acute accent - "\u00CE" to "Î", // Î - uppercase I, circumflex accent - "\u00CF" to "Ï", // Ï - uppercase I, umlaut - "\u00D0" to "Ð", // Ð - uppercase Eth, Icelandic - "\u00D1" to "Ñ", // Ñ - uppercase N, tilde - "\u00D2" to "Ò", // Ò - uppercase O, grave accent - "\u00D3" to "Ó", // Ó - uppercase O, acute accent - "\u00D4" to "Ô", // Ô - uppercase O, circumflex accent - "\u00D5" to "Õ", // Õ - uppercase O, tilde - "\u00D6" to "Ö", // Ö - uppercase O, umlaut - "\u00D7" to "×", // multiplication sign - "\u00D8" to "Ø", // Ø - uppercase O, slash - "\u00D9" to "Ù", // Ù - uppercase U, grave accent - "\u00DA" to "Ú", // Ú - uppercase U, acute accent - "\u00DB" to "Û", // Û - uppercase U, circumflex accent - "\u00DC" to "Ü", // Ü - uppercase U, umlaut - "\u00DD" to "Ý", // Ý - uppercase Y, acute accent - "\u00DE" to "Þ", // Þ - uppercase THORN, Icelandic - "\u00DF" to "ß", // ß - lowercase sharps, German - "\u00E0" to "à", // à - lowercase a, grave accent - "\u00E1" to "á", // á - lowercase a, acute accent - "\u00E2" to "â", // â - lowercase a, circumflex accent - "\u00E3" to "ã", // ã - lowercase a, tilde - "\u00E4" to "ä", // ä - lowercase a, umlaut - "\u00E5" to "å", // å - lowercase a, ring - "\u00E6" to "æ", // æ - lowercase ae - "\u00E7" to "ç", // ç - lowercase c, cedilla - "\u00E8" to "è", // è - lowercase e, grave accent - "\u00E9" to "é", // é - lowercase e, acute accent - "\u00EA" to "ê", // ê - lowercase e, circumflex accent - "\u00EB" to "ë", // ë - lowercase e, umlaut - "\u00EC" to "ì", // ì - lowercase i, grave accent - "\u00ED" to "í", // í - lowercase i, acute accent - "\u00EE" to "î", // î - lowercase i, circumflex accent - "\u00EF" to "ï", // ï - lowercase i, umlaut - "\u00F0" to "ð", // ð - lowercase eth, Icelandic - "\u00F1" to "ñ", // ñ - lowercase n, tilde - "\u00F2" to "ò", // ò - lowercase o, grave accent - "\u00F3" to "ó", // ó - lowercase o, acute accent - "\u00F4" to "ô", // ô - lowercase o, circumflex accent - "\u00F5" to "õ", // õ - lowercase o, tilde - "\u00F6" to "ö", // ö - lowercase o, umlaut - "\u00F7" to "÷", // division sign - "\u00F8" to "ø", // ø - lowercase o, slash - "\u00F9" to "ù", // ù - lowercase u, grave accent - "\u00FA" to "ú", // ú - lowercase u, acute accent - "\u00FB" to "û", // û - lowercase u, circumflex accent - "\u00FC" to "ü", // ü - lowercase u, umlaut - "\u00FD" to "ý", // ý - lowercase y, acute accent - "\u00FE" to "þ", // þ - lowercase thorn, Icelandic - "\u00FF" to "ÿ" // ÿ - lowercase y, umlaut - ) - - /** - * Reverse of [.ISO8859_1_ESCAPE] for unescaping purposes. - */ - val ISO8859_1_UNESCAPE: Map = ISO8859_1_ESCAPE.invert() - - /** - * A Map<CharSequence, CharSequence> to escape additional - * [character entity references](http://www.w3.org/TR/REC-html40/sgml/entities.html). - * Note that this must be used with [.ISO8859_1_ESCAPE] to get the full list of - * HTML 4.0 character entities. - */ - val HTML40_EXTENDED_ESCAPE: Map = mapOf( - // - "\u0192" to "ƒ", // latin small f with hook = function= florin, U+0192 ISOtech --> - // - "\u0391" to "Α", // greek capital letter alpha, U+0391 --> - "\u0392" to "Β", // greek capital letter beta, U+0392 --> - "\u0393" to "Γ", // greek capital letter gamma,U+0393 ISOgrk3 --> - "\u0394" to "Δ", // greek capital letter delta,U+0394 ISOgrk3 --> - "\u0395" to "Ε", // greek capital letter epsilon, U+0395 --> - "\u0396" to "Ζ", // greek capital letter zeta, U+0396 --> - "\u0397" to "Η", // greek capital letter eta, U+0397 --> - "\u0398" to "Θ", // greek capital letter theta,U+0398 ISOgrk3 --> - "\u0399" to "Ι", // greek capital letter iota, U+0399 --> - "\u039A" to "Κ", // greek capital letter kappa, U+039A --> - "\u039B" to "Λ", // greek capital letter lambda,U+039B ISOgrk3 --> - "\u039C" to "Μ", // greek capital letter mu, U+039C --> - "\u039D" to "Ν", // greek capital letter nu, U+039D --> - "\u039E" to "Ξ", // greek capital letter xi, U+039E ISOgrk3 --> - "\u039F" to "Ο", // greek capital letter omicron, U+039F --> - "\u03A0" to "Π", // greek capital letter pi, U+03A0 ISOgrk3 --> - "\u03A1" to "Ρ", // greek capital letter rho, U+03A1 --> - // - "\u03A3" to "Σ", // greek capital letter sigma,U+03A3 ISOgrk3 --> - "\u03A4" to "Τ", // greek capital letter tau, U+03A4 --> - "\u03A5" to "Υ", // greek capital letter upsilon,U+03A5 ISOgrk3 --> - "\u03A6" to "Φ", // greek capital letter phi,U+03A6 ISOgrk3 --> - "\u03A7" to "Χ", // greek capital letter chi, U+03A7 --> - "\u03A8" to "Ψ", // greek capital letter psi,U+03A8 ISOgrk3 --> - "\u03A9" to "Ω", // greek capital letter omega,U+03A9 ISOgrk3 --> - "\u03B1" to "α", // greek small letter alpha,U+03B1 ISOgrk3 --> - "\u03B2" to "β", // greek small letter beta, U+03B2 ISOgrk3 --> - "\u03B3" to "γ", // greek small letter gamma,U+03B3 ISOgrk3 --> - "\u03B4" to "δ", // greek small letter delta,U+03B4 ISOgrk3 --> - "\u03B5" to "ε", // greek small letter epsilon,U+03B5 ISOgrk3 --> - "\u03B6" to "ζ", // greek small letter zeta, U+03B6 ISOgrk3 --> - "\u03B7" to "η", // greek small letter eta, U+03B7 ISOgrk3 --> - "\u03B8" to "θ", // greek small letter theta,U+03B8 ISOgrk3 --> - "\u03B9" to "ι", // greek small letter iota, U+03B9 ISOgrk3 --> - "\u03BA" to "κ", // greek small letter kappa,U+03BA ISOgrk3 --> - "\u03BB" to "λ", // greek small letter lambda,U+03BB ISOgrk3 --> - "\u03BC" to "μ", // greek small letter mu, U+03BC ISOgrk3 --> - "\u03BD" to "ν", // greek small letter nu, U+03BD ISOgrk3 --> - "\u03BE" to "ξ", // greek small letter xi, U+03BE ISOgrk3 --> - "\u03BF" to "ο", // greek small letter omicron, U+03BF NEW --> - "\u03C0" to "π", // greek small letter pi, U+03C0 ISOgrk3 --> - "\u03C1" to "ρ", // greek small letter rho, U+03C1 ISOgrk3 --> - "\u03C2" to "ς", // greek small letter final sigma,U+03C2 ISOgrk3 --> - "\u03C3" to "σ", // greek small letter sigma,U+03C3 ISOgrk3 --> - "\u03C4" to "τ", // greek small letter tau, U+03C4 ISOgrk3 --> - "\u03C5" to "υ", // greek small letter upsilon,U+03C5 ISOgrk3 --> - "\u03C6" to "φ", // greek small letter phi, U+03C6 ISOgrk3 --> - "\u03C7" to "χ", // greek small letter chi, U+03C7 ISOgrk3 --> - "\u03C8" to "ψ", // greek small letter psi, U+03C8 ISOgrk3 --> - "\u03C9" to "ω", // greek small letter omega,U+03C9 ISOgrk3 --> - "\u03D1" to "ϑ", // greek small letter theta symbol,U+03D1 NEW --> - "\u03D2" to "ϒ", // greek upsilon with hook symbol,U+03D2 NEW --> - "\u03D6" to "ϖ", // greek pi symbol, U+03D6 ISOgrk3 --> - // - "\u2022" to "•", // bullet = black small circle,U+2022 ISOpub --> - // - "\u2026" to "…", // horizontal ellipsis = three dot leader,U+2026 ISOpub --> - "\u2032" to "′", // prime = minutes = feet, U+2032 ISOtech --> - "\u2033" to "″", // double prime = seconds = inches,U+2033 ISOtech --> - "\u203E" to "‾", // overline = spacing overscore,U+203E NEW --> - "\u2044" to "⁄", // fraction slash, U+2044 NEW --> - // - "\u2118" to "℘", // script capital P = power set= Weierstrass p, U+2118 ISOamso --> - "\u2111" to "ℑ", // blackletter capital I = imaginary part,U+2111 ISOamso --> - "\u211C" to "ℜ", // blackletter capital R = real part symbol,U+211C ISOamso --> - "\u2122" to "™", // trade mark sign, U+2122 ISOnum --> - "\u2135" to "ℵ", // alef symbol = first transfinite cardinal,U+2135 NEW --> - // - // - "\u2190" to "←", // leftwards arrow, U+2190 ISOnum --> - "\u2191" to "↑", // upwards arrow, U+2191 ISOnum--> - "\u2192" to "→", // rightwards arrow, U+2192 ISOnum --> - "\u2193" to "↓", // downwards arrow, U+2193 ISOnum --> - "\u2194" to "↔", // left right arrow, U+2194 ISOamsa --> - "\u21B5" to "↵", // downwards arrow with corner leftwards= carriage return, U+21B5 NEW --> - "\u21D0" to "⇐", // leftwards double arrow, U+21D0 ISOtech --> - // - "\u21D1" to "⇑", // upwards double arrow, U+21D1 ISOamsa --> - "\u21D2" to "⇒", // rightwards double arrow,U+21D2 ISOtech --> - // - "\u21D3" to "⇓", // downwards double arrow, U+21D3 ISOamsa --> - "\u21D4" to "⇔", // left right double arrow,U+21D4 ISOamsa --> - // - "\u2200" to "∀", // for all, U+2200 ISOtech --> - "\u2202" to "∂", // partial differential, U+2202 ISOtech --> - "\u2203" to "∃", // there exists, U+2203 ISOtech --> - "\u2205" to "∅", // empty set = null set = diameter,U+2205 ISOamso --> - "\u2207" to "∇", // nabla = backward difference,U+2207 ISOtech --> - "\u2208" to "∈", // element of, U+2208 ISOtech --> - "\u2209" to "∉", // not an element of, U+2209 ISOtech --> - "\u220B" to "∋", // contains as member, U+220B ISOtech --> - // - "\u220F" to "∏", // n-ary product = product sign,U+220F ISOamsb --> - // - "\u2211" to "∑", // n-ary summation, U+2211 ISOamsb --> - // - "\u2212" to "−", // minus sign, U+2212 ISOtech --> - "\u2217" to "∗", // asterisk operator, U+2217 ISOtech --> - "\u221A" to "√", // square root = radical sign,U+221A ISOtech --> - "\u221D" to "∝", // proportional to, U+221D ISOtech --> - "\u221E" to "∞", // infinity, U+221E ISOtech --> - "\u2220" to "∠", // angle, U+2220 ISOamso --> - "\u2227" to "∧", // logical and = wedge, U+2227 ISOtech --> - "\u2228" to "∨", // logical or = vee, U+2228 ISOtech --> - "\u2229" to "∩", // intersection = cap, U+2229 ISOtech --> - "\u222A" to "∪", // union = cup, U+222A ISOtech --> - "\u222B" to "∫", // integral, U+222B ISOtech --> - "\u2234" to "∴", // therefore, U+2234 ISOtech --> - "\u223C" to "∼", // tilde operator = varies with = similar to,U+223C ISOtech --> - // - "\u2245" to "≅", // approximately equal to, U+2245 ISOtech --> - "\u2248" to "≈", // almost equal to = asymptotic to,U+2248 ISOamsr --> - "\u2260" to "≠", // not equal to, U+2260 ISOtech --> - "\u2261" to "≡", // identical to, U+2261 ISOtech --> - "\u2264" to "≤", // less-than or equal to, U+2264 ISOtech --> - "\u2265" to "≥", // greater-than or equal to,U+2265 ISOtech --> - "\u2282" to "⊂", // subset of, U+2282 ISOtech --> - "\u2283" to "⊃", // superset of, U+2283 ISOtech --> - // , - "\u2284" to "⊄", // not a subset of, U+2284 ISOamsn --> - "\u2286" to "⊆", // subset of or equal to, U+2286 ISOtech --> - "\u2287" to "⊇", // superset of or equal to,U+2287 ISOtech --> - "\u2295" to "⊕", // circled plus = direct sum,U+2295 ISOamsb --> - "\u2297" to "⊗", // circled times = vector product,U+2297 ISOamsb --> - "\u22A5" to "⊥", // up tack = orthogonal to = perpendicular,U+22A5 ISOtech --> - "\u22C5" to "⋅", // dot operator, U+22C5 ISOamsb --> - // - // - "\u2308" to "⌈", // left ceiling = apl upstile,U+2308 ISOamsc --> - "\u2309" to "⌉", // right ceiling, U+2309 ISOamsc --> - "\u230A" to "⌊", // left floor = apl downstile,U+230A ISOamsc --> - "\u230B" to "⌋", // right floor, U+230B ISOamsc --> - "\u2329" to "⟨", // left-pointing angle bracket = bra,U+2329 ISOtech --> - // - "\u232A" to "⟩", // right-pointing angle bracket = ket,U+232A ISOtech --> - // - // - "\u25CA" to "◊", // lozenge, U+25CA ISOpub --> - // - "\u2660" to "♠", // black spade suit, U+2660 ISOpub --> - // - "\u2663" to "♣", // black club suit = shamrock,U+2663 ISOpub --> - "\u2665" to "♥", // black heart suit = valentine,U+2665 ISOpub --> - "\u2666" to "♦", // black diamond suit, U+2666 ISOpub --> - - // - "\u0152" to "Œ", // -- latin capital ligature OE,U+0152 ISOlat2 --> - "\u0153" to "œ", // -- latin small ligature oe, U+0153 ISOlat2 --> - // - "\u0160" to "Š", // -- latin capital letter S with caron,U+0160 ISOlat2 --> - "\u0161" to "š", // -- latin small letter s with caron,U+0161 ISOlat2 --> - "\u0178" to "Ÿ", // -- latin capital letter Y with diaeresis,U+0178 ISOlat2 --> - // - "\u02C6" to "ˆ", // -- modifier letter circumflex accent,U+02C6 ISOpub --> - "\u02DC" to "˜", // small tilde, U+02DC ISOdia --> - // - "\u2002" to " ", // en space, U+2002 ISOpub --> - "\u2003" to " ", // em space, U+2003 ISOpub --> - "\u2009" to " ", // thin space, U+2009 ISOpub --> - "\u200C" to "‌", // zero width non-joiner,U+200C NEW RFC 2070 --> - "\u200D" to "‍", // zero width joiner, U+200D NEW RFC 2070 --> - "\u200E" to "‎", // left-to-right mark, U+200E NEW RFC 2070 --> - "\u200F" to "‏", // right-to-left mark, U+200F NEW RFC 2070 --> - "\u2013" to "–", // en dash, U+2013 ISOpub --> - "\u2014" to "—", // em dash, U+2014 ISOpub --> - "\u2018" to "‘", // left single quotation mark,U+2018 ISOnum --> - "\u2019" to "’", // right single quotation mark,U+2019 ISOnum --> - "\u201A" to "‚", // single low-9 quotation mark, U+201A NEW --> - "\u201C" to "“", // left double quotation mark,U+201C ISOnum --> - "\u201D" to "”", // right double quotation mark,U+201D ISOnum --> - "\u201E" to "„", // double low-9 quotation mark, U+201E NEW --> - "\u2020" to "†", // dagger, U+2020 ISOpub --> - "\u2021" to "‡", // double dagger, U+2021 ISOpub --> - "\u2030" to "‰", // per mille sign, U+2030 ISOtech --> - "\u2039" to "‹", // single left-pointing angle quotation mark,U+2039 ISO proposed --> - // - "\u203A" to "›", // single right-pointing angle quotation mark,U+203A ISO proposed --> - // - "\u20AC" to "€" // -- euro sign, U+20AC NEW --> - ) - - /** - * Reverse of [.HTML40_EXTENDED_ESCAPE] for unescaping purposes. - */ - val HTML40_EXTENDED_UNESCAPE: Map = HTML40_EXTENDED_ESCAPE.invert() - - /** - * A Map<CharSequence, CharSequence> to escape the basic XML and HTML - * character entities. - * - * Namely: `" & < >` - */ - val BASIC_ESCAPE: Map = mapOf( - "\"" to """, // " - double-quote - "&" to "&", // & - ampersand - "<" to "<", // < - less-than - ">" to ">" // > - greater-than - ) - - /** - * Reverse of [.BASIC_ESCAPE] for unescaping purposes. - */ - val BASIC_UNESCAPE: Map = BASIC_ESCAPE.invert() - - /** - * A Map<CharSequence, CharSequence> to escape the apostrophe character to - * its XML character entity. - */ - val APOS_ESCAPE: Map = mapOf( - "'" to "'" // XML apostrophe - ) - - /** - * Reverse of [.APOS_ESCAPE] for unescaping purposes. - */ - val APOS_UNESCAPE: Map = APOS_ESCAPE.invert() - - /** - * Used to invert an escape Map into an unescape Map. - * @param this@invert Map<String, String> to be inverted - * @return Map<String, String> inverted array - */ - private fun Map.invert(): Map { - val newMap = HashMap() - val it = entries.iterator() - while (it.hasNext()) { - val pair = it.next() - newMap[pair.value] = pair.key - } - return newMap - } - -} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/HtmlEscapeHelper.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/HtmlEscapeHelper.kt index e884fd7d7..bb45c1e21 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/HtmlEscapeHelper.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/HtmlEscapeHelper.kt @@ -1,18 +1,18 @@ /* * Twidere - Twitter client for Android - * + * * Copyright (C) 2012-2014 Mariotaku Lee - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -21,6 +21,7 @@ package org.mariotaku.twidere.util import org.apache.commons.text.translate.AggregateTranslator import org.apache.commons.text.translate.CodePointTranslator +import org.apache.commons.text.translate.EntityArrays import org.apache.commons.text.translate.LookupTranslator import org.apache.commons.text.translate.NumericEntityUnescaper import java.io.IOException diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/concurrent/ConstantFuture.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/concurrent/ConstantFuture.kt deleted file mode 100644 index e9481b3e2..000000000 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/concurrent/ConstantFuture.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Twidere - Twitter client for Android - * - * Copyright (C) 2012-2017 Mariotaku Lee - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.mariotaku.twidere.util.concurrent - -import java.util.concurrent.Future -import java.util.concurrent.TimeUnit - -/** - * Created by mariotaku on 2017/9/25. - */ -class ConstantFuture(private val value: V) : Future { - override fun isDone() = true - - override fun get() = value - - override fun get(time: Long, unit: TimeUnit?) = value - - override fun isCancelled() = false - - override fun cancel(mayInterruptIfRunning: Boolean) = false -} \ No newline at end of file