mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-05 21:43:40 +01:00
General kotlinification.
Signed-off-by: Dominic Fischer <dominicfischer7@gmail.com>
This commit is contained in:
parent
2cf63ea92a
commit
5ab975cc5c
@ -66,7 +66,7 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
|
|||||||
if (':' in userId) {
|
if (':' in userId) {
|
||||||
try {
|
try {
|
||||||
synchronized(notReadyToRetryHS) {
|
synchronized(notReadyToRetryHS) {
|
||||||
res = !notReadyToRetryHS.contains(userId.substring(userId.lastIndexOf(":") + 1))
|
res = !notReadyToRetryHS.contains(userId.substringAfterLast(':'))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## canRetryKeysDownload() failed")
|
Timber.e(e, "## canRetryKeysDownload() failed")
|
||||||
|
@ -216,7 +216,7 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
|
|||||||
sendMessageToDevices(requestMessage, request.recipients, request.requestId, object : MatrixCallback<Unit> {
|
sendMessageToDevices(requestMessage, request.recipients, request.requestId, object : MatrixCallback<Unit> {
|
||||||
private fun onDone(state: OutgoingRoomKeyRequest.RequestState) {
|
private fun onDone(state: OutgoingRoomKeyRequest.RequestState) {
|
||||||
if (request.state !== OutgoingRoomKeyRequest.RequestState.UNSENT) {
|
if (request.state !== OutgoingRoomKeyRequest.RequestState.UNSENT) {
|
||||||
Timber.v("## sendOutgoingRoomKeyRequest() : Cannot update room key request from UNSENT as it was already updated to " + request.state)
|
Timber.v("## sendOutgoingRoomKeyRequest() : Cannot update room key request from UNSENT as it was already updated to ${request.state}")
|
||||||
} else {
|
} else {
|
||||||
request.state = state
|
request.state = state
|
||||||
cryptoStore.updateOutgoingRoomKeyRequest(request)
|
cryptoStore.updateOutgoingRoomKeyRequest(request)
|
||||||
|
@ -342,10 +342,8 @@ internal class DefaultSasVerificationService @Inject constructor(private val cre
|
|||||||
private fun addTransaction(tx: VerificationTransaction) {
|
private fun addTransaction(tx: VerificationTransaction) {
|
||||||
tx.otherUserId.let { otherUserId ->
|
tx.otherUserId.let { otherUserId ->
|
||||||
synchronized(txMap) {
|
synchronized(txMap) {
|
||||||
if (txMap[otherUserId] == null) {
|
val txInnerMap = txMap.getOrPut(otherUserId) { HashMap() }
|
||||||
txMap[otherUserId] = HashMap()
|
txInnerMap[tx.transactionId] = tx
|
||||||
}
|
|
||||||
txMap[otherUserId]?.set(tx.transactionId, tx)
|
|
||||||
dispatchTxAdded(tx)
|
dispatchTxAdded(tx)
|
||||||
tx.addListener(this)
|
tx.addListener(this)
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.riotx.core.linkify
|
package im.vector.riotx.core.linkify
|
||||||
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Better support for geo URi
|
* Better support for geo URi
|
||||||
*/
|
*/
|
||||||
@ -26,7 +24,7 @@ object VectorAutoLinkPatterns {
|
|||||||
private const val LAT_OR_LONG_OR_ALT_NUMBER = "-?\\d+(?:\\.\\d+)?"
|
private const val LAT_OR_LONG_OR_ALT_NUMBER = "-?\\d+(?:\\.\\d+)?"
|
||||||
private const val COORDINATE_SYSTEM = ";crs=[\\w-]+"
|
private const val COORDINATE_SYSTEM = ";crs=[\\w-]+"
|
||||||
|
|
||||||
val GEO_URI: Pattern = Pattern.compile("(?:geo:)?" +
|
val GEO_URI: Regex = Regex("(?:geo:)?" +
|
||||||
"(" + LAT_OR_LONG_OR_ALT_NUMBER + ")" +
|
"(" + LAT_OR_LONG_OR_ALT_NUMBER + ")" +
|
||||||
"," +
|
"," +
|
||||||
"(" + LAT_OR_LONG_OR_ALT_NUMBER + ")" +
|
"(" + LAT_OR_LONG_OR_ALT_NUMBER + ")" +
|
||||||
@ -35,5 +33,5 @@ object VectorAutoLinkPatterns {
|
|||||||
"(?:" + ";u=\\d+(?:\\.\\d+)?" + ")?" + // uncertainty in meters
|
"(?:" + ";u=\\d+(?:\\.\\d+)?" + ")?" + // uncertainty in meters
|
||||||
"(?:" +
|
"(?:" +
|
||||||
";[\\w-]+=(?:[\\w-_.!~*'()]|%[\\da-f][\\da-f])+" + // dafuk
|
";[\\w-]+=(?:[\\w-_.!~*'()]|%[\\da-f][\\da-f])+" + // dafuk
|
||||||
")*", Pattern.CASE_INSENSITIVE)
|
")*", RegexOption.IGNORE_CASE)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ object VectorLinkify {
|
|||||||
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
|
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkifyCompat.addLinks(spannable, VectorAutoLinkPatterns.GEO_URI, "geo:", arrayOf("geo:"), geoMatchFilter, null)
|
LinkifyCompat.addLinks(spannable, VectorAutoLinkPatterns.GEO_URI.toPattern(), "geo:", arrayOf("geo:"), geoMatchFilter, null)
|
||||||
spannable.forEachSpanIndexed { _, urlSpan, start, end ->
|
spannable.forEachSpanIndexed { _, urlSpan, start, end ->
|
||||||
spannable.removeSpan(urlSpan)
|
spannable.removeSpan(urlSpan)
|
||||||
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
|
createdSpans.add(LinkSpec(URLSpan(urlSpan.url), start, end))
|
||||||
|
@ -24,6 +24,7 @@ import im.vector.riotx.core.resources.LocaleProvider
|
|||||||
import im.vector.riotx.core.resources.StringProvider
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
private const val DEFAULT_PUSHER_FILE_TAG = "mobile"
|
private const val DEFAULT_PUSHER_FILE_TAG = "mobile"
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ class PushersManager @Inject constructor(
|
|||||||
|
|
||||||
fun registerPusherWithFcmKey(pushKey: String): UUID {
|
fun registerPusherWithFcmKey(pushKey: String): UUID {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
var profileTag = DEFAULT_PUSHER_FILE_TAG + "_" + Math.abs(currentSession.myUserId.hashCode())
|
val profileTag = DEFAULT_PUSHER_FILE_TAG + "_" + abs(currentSession.myUserId.hashCode())
|
||||||
|
|
||||||
return currentSession.addHttpPusher(
|
return currentSession.addHttpPusher(
|
||||||
pushKey,
|
pushKey,
|
||||||
|
@ -59,9 +59,10 @@ fun initKnownEmojiHashSet(context: Context, done: (() -> Unit)? = null) {
|
|||||||
val jsonAdapter = moshi.adapter(EmojiDataSource.EmojiData::class.java)
|
val jsonAdapter = moshi.adapter(EmojiDataSource.EmojiData::class.java)
|
||||||
val inputAsString = input.bufferedReader().use { it.readText() }
|
val inputAsString = input.bufferedReader().use { it.readText() }
|
||||||
val source = jsonAdapter.fromJson(inputAsString)
|
val source = jsonAdapter.fromJson(inputAsString)
|
||||||
knownEmojiSet = HashSet<String>()
|
knownEmojiSet = HashSet<String>().also {
|
||||||
source?.emojis?.values?.forEach {
|
source?.emojis?.mapTo(it) { (_, value) ->
|
||||||
knownEmojiSet?.add(it.emojiString())
|
value.emojiString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
done?.invoke()
|
done?.invoke()
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class ViewEditHistoryEpoxyController(private val context: Context,
|
|||||||
val body = cContent.second?.let { eventHtmlRenderer.render(it) }
|
val body = cContent.second?.let { eventHtmlRenderer.render(it) }
|
||||||
?: cContent.first
|
?: cContent.first
|
||||||
|
|
||||||
val nextEvent = if (index + 1 <= sourceEvents.lastIndex) sourceEvents[index + 1] else null
|
val nextEvent = sourceEvents.getOrNull(index + 1)
|
||||||
|
|
||||||
var spannedDiff: Spannable? = null
|
var spannedDiff: Spannable? = null
|
||||||
if (nextEvent != null && cContent.second == null /*No diff for html*/) {
|
if (nextEvent != null && cContent.second == null /*No diff for html*/) {
|
||||||
|
@ -130,24 +130,16 @@ object ThemeUtils {
|
|||||||
*/
|
*/
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun getColor(c: Context, @AttrRes colorAttribute: Int): Int {
|
fun getColor(c: Context, @AttrRes colorAttribute: Int): Int {
|
||||||
if (mColorByAttr.containsKey(colorAttribute)) {
|
return mColorByAttr.getOrPut(colorAttribute) {
|
||||||
return mColorByAttr[colorAttribute] as Int
|
try {
|
||||||
|
val color = TypedValue()
|
||||||
|
c.theme.resolveAttribute(colorAttribute, color, true)
|
||||||
|
color.data
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.e(e, "Unable to get color")
|
||||||
|
ContextCompat.getColor(c, android.R.color.holo_red_dark)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var matchedColor: Int
|
|
||||||
|
|
||||||
try {
|
|
||||||
val color = TypedValue()
|
|
||||||
c.theme.resolveAttribute(colorAttribute, color, true)
|
|
||||||
matchedColor = color.data
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Timber.e(e, "Unable to get color")
|
|
||||||
matchedColor = ContextCompat.getColor(c, android.R.color.holo_red_dark)
|
|
||||||
}
|
|
||||||
|
|
||||||
mColorByAttr[colorAttribute] = matchedColor
|
|
||||||
|
|
||||||
return matchedColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAttribute(c: Context, @AttrRes attribute: Int): TypedValue? {
|
fun getAttribute(c: Context, @AttrRes attribute: Int): TypedValue? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user