Fix ktlint issue automatically by running `./ktlint --android -v -F`

This commit is contained in:
Benoit Marty 2019-10-09 15:24:05 +02:00
parent dceb5ffd8d
commit 15dc4d6369
927 changed files with 1312 additions and 2546 deletions

View File

@ -19,7 +19,6 @@ package im.vector.matrix.rx
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.util.Cancelable
import io.reactivex.CompletableEmitter
import io.reactivex.SingleEmitter
internal class MatrixCallbackCompletable<T>(private val completableEmitter: CompletableEmitter) : MatrixCallback<T> {

View File

@ -67,7 +67,6 @@ class RxRoom(private val room: Room) {
fun liveDrafts(): Observable<List<UserDraft>> {
return room.getDraftsLive().asObservable()
}
}
fun Room.rx(): RxRoom {

View File

@ -71,7 +71,6 @@ class RxSession(private val session: Session) {
fun joinRoom(roomId: String, viaServers: List<String> = emptyList()): Single<Unit> = Single.create {
session.joinRoom(roomId, viaServers, MatrixCallbackSingle(it)).toSingle(it)
}
}
fun Session.rx(): RxSession {

View File

@ -28,7 +28,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
internal class AuthenticatorTest : InstrumentedTest {
@ -50,7 +49,6 @@ internal class AuthenticatorTest : InstrumentedTest {
@UiThreadTest
@OkReplay(tape = "auth", mode = TapeMode.READ_WRITE)
fun auth() {
}
companion object {
@ -59,6 +57,4 @@ internal class AuthenticatorTest : InstrumentedTest {
val grantExternalStoragePermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
}
}

View File

@ -62,8 +62,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
JsonCanonicalizer.canonicalize("{\"a\":\"\\\"\"}"))
}
/* ==========================================================================================
* Test from https://matrix.org/docs/spec/appendices.html#examples
* ========================================================================================== */
@ -74,7 +72,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
JsonCanonicalizer.canonicalize("""{}"""))
}
@Test
fun matrixOrg002Test() {
assertEquals("""{"one":1,"two":"Two"}""",
@ -84,7 +81,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
}"""))
}
@Test
fun matrixOrg003Test() {
assertEquals("""{"a":"1","b":"2"}""",
@ -94,14 +90,12 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
}"""))
}
@Test
fun matrixOrg004Test() {
assertEquals("""{"a":"1","b":"2"}""",
JsonCanonicalizer.canonicalize("""{"b":"2","a":"1"}"""))
}
@Test
fun matrixOrg005Test() {
assertEquals("""{"auth":{"mxid":"@john.doe:example.com","profile":{"display_name":"John Doe","three_pids":[{"address":"john.doe@example.org","medium":"email"},{"address":"123456789","medium":"msisdn"}]},"success":true}}""",
@ -126,7 +120,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
}"""))
}
@Test
fun matrixOrg006Test() {
assertEquals("""{"a":"日本語"}""",
@ -135,7 +128,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
}"""))
}
@Test
fun matrixOrg007Test() {
assertEquals("""{"日":1,"本":2}""",
@ -145,7 +137,6 @@ internal class JsonCanonicalizerTest : InstrumentedTest {
}"""))
}
@Test
fun matrixOrg008Test() {
assertEquals("""{"a":"日"}""",

View File

@ -35,7 +35,6 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
internal class ChunkEntityTest : InstrumentedTest {
@ -48,7 +47,6 @@ internal class ChunkEntityTest : InstrumentedTest {
monarchy = Monarchy.Builder().setRealmConfiguration(testConfig).build()
}
@Test
fun add_shouldAdd_whenNotAlreadyIncluded() {
monarchy.runTransactionSync { realm ->
@ -194,5 +192,4 @@ internal class ChunkEntityTest : InstrumentedTest {
chunk1.nextToken shouldEqual nextToken
}
}
}

View File

@ -32,6 +32,4 @@ internal class FakeGetContextOfEventTask constructor(private val tokenChunkEvent
)
return tokenChunkEventPersistor.insertInDb(tokenChunkEvent, params.roomId, PaginationDirection.BACKWARDS)
}
}

View File

@ -28,6 +28,4 @@ internal class FakePaginationTask @Inject constructor(private val tokenChunkEven
val tokenChunkEvent = FakeTokenChunkEvent(params.from, Random.nextLong(System.currentTimeMillis()).toString(), fakeEvents)
return tokenChunkEventPersistor.insertInDb(tokenChunkEvent, params.roomId, params.direction)
}
}

View File

@ -88,6 +88,4 @@ object RoomDataHelper {
roomEntity.addOrUpdate(chunkEntity)
}
}
}

View File

@ -81,6 +81,4 @@ internal class TimelineTest : InstrumentedTest {
// timelineEvents.size shouldEqual initialLoad + paginationCount
// timeline.dispose()
// }
}

View File

@ -51,7 +51,6 @@ class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
// Finally this is not a JSON string...
Timber.e(e)
}
} else if (message.startsWith("[")) {
// JSON Array detected
try {
@ -61,7 +60,6 @@ class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
// Finally not JSON...
Timber.e(e)
}
}
// Else not a json string to log
}

View File

@ -38,7 +38,6 @@ data class MatrixConfiguration(
interface Provider {
fun providesMatrixConfiguration(): MatrixConfiguration
}
}
/**
@ -98,5 +97,4 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
return BuildConfig.VERSION_NAME + " (" + BuildConfig.GIT_SDK_REVISION + ")"
}
}
}

View File

@ -27,7 +27,7 @@ interface MatrixCallback<in T> {
* @param data the data successfully returned from the async function
*/
fun onSuccess(data: T) {
//no-op
// no-op
}
/**
@ -35,7 +35,6 @@ interface MatrixCallback<in T> {
* @param failure the failure data returned from the async function
*/
fun onFailure(failure: Throwable) {
//no-op
// no-op
}
}

View File

@ -16,7 +16,6 @@
package im.vector.matrix.android.api
/**
* This class contains pattern to match the different Matrix ids
*/
@ -154,6 +153,5 @@ object MatrixPatterns {
return if (index == -1) {
null
} else matrixId.substring(index + 1)
}
}

View File

@ -253,13 +253,5 @@ data class HomeServerConnectionConfig(
forceUsageTlsVersions
)
}
}
}

View File

@ -29,7 +29,6 @@ fun MXDeviceInfo.getFingerprintHumanReadable() = fingerprint()
?.chunked(4)
?.joinToString(separator = " ")
fun List<DeviceInfo>.sortByLastSeen() {
Collections.sort(this, DatedObjectComparators.descComparator)
}

View File

@ -42,5 +42,4 @@ sealed class Failure(cause: Throwable? = null) : Throwable(cause = cause) {
data class CryptoError(val error: MXCryptoError) : Failure(error)
abstract class FeatureFailure : Failure()
}

View File

@ -33,7 +33,6 @@ data class MatrixError(
@Json(name = "limit_type") val limitType: String? = null,
@Json(name = "admin_contact") val adminUri: String? = null) {
companion object {
const val FORBIDDEN = "M_FORBIDDEN"
const val UNKNOWN = "M_UNKNOWN"

View File

@ -51,5 +51,4 @@ object MatrixLinkify {
}
return hasMatch
}
}

View File

@ -35,6 +35,4 @@ class MatrixPermalinkSpan(private val url: String,
override fun onClick(widget: View) {
callback?.onUrlClicked(url)
}
}

View File

@ -33,5 +33,4 @@ sealed class PermalinkData {
data class GroupLink(val groupId: String) : PermalinkData()
data class FallbackLink(val uri: Uri) : PermalinkData()
}

View File

@ -51,7 +51,6 @@ object PermalinkFactory {
return if (TextUtils.isEmpty(id)) {
null
} else MATRIX_TO_URL_BASE + escape(id)
}
/**
@ -78,10 +77,8 @@ object PermalinkFactory {
return if (isSupported) {
url!!.substring(MATRIX_TO_URL_BASE.length)
} else null
}
/**
* Escape '/' in id, because it is used as a separator
*

View File

@ -72,5 +72,4 @@ object PermalinkParser {
else -> PermalinkData.FallbackLink(uri)
}
}
}

View File

@ -18,7 +18,6 @@ package im.vector.matrix.android.api.pushrules
import im.vector.matrix.android.api.pushrules.rest.PushRule
import timber.log.Timber
sealed class Action {
object Notify : Action()
object DoNotNotify : Action()
@ -26,7 +25,6 @@ sealed class Action {
data class Highlight(val highlight: Boolean) : Action()
}
private const val ACTION_NOTIFY = "notify"
private const val ACTION_DONT_NOTIFY = "dont_notify"
private const val ACTION_COALESCE = "coalesce"
@ -80,7 +78,6 @@ fun PushRule.getActions(): List<Action> {
}
// When the value is not there, default sound (not specified by the spec)
?: Action.Sound(ACTION_OBJECT_VALUE_VALUE_DEFAULT)
}
ACTION_OBJECT_SET_TWEAK_VALUE_HIGHLIGHT -> {
(actionStrOrObj[ACTION_OBJECT_VALUE_KEY] as? Boolean)?.let { boolValue ->
@ -104,7 +101,5 @@ fun PushRule.getActions(): List<Action> {
}
}
return result
}

View File

@ -35,9 +35,7 @@ abstract class Condition(val kind: Kind) {
else -> UNRECOGNIZE
}
}
}
}
abstract fun isSatisfied(conditionResolver: ConditionResolver): Boolean

View File

@ -38,7 +38,7 @@ class ContainsDisplayNameCondition : Condition(Kind.contains_display_name) {
EventType.MESSAGE -> {
event.content.toModel<MessageContent>()
}
//TODO the spec says:
// TODO the spec says:
// Matches any message whose content is unencrypted and contains the user's current display name
// EventType.ENCRYPTED -> {
// event.root.getClearContent()?.toModel<MessageContent>()
@ -49,7 +49,6 @@ class ContainsDisplayNameCondition : Condition(Kind.contains_display_name) {
return caseInsensitiveFind(displayName, message.body)
}
companion object {
/**
* Returns whether a string contains an occurrence of another, as a standalone word, regardless of case.

View File

@ -29,28 +29,25 @@ class EventMatchCondition(val key: String, val pattern: String) : Condition(Kind
return "'$key' Matches '$pattern'"
}
fun isSatisfied(event: Event): Boolean {
//TODO encrypted events?
// TODO encrypted events?
val rawJson = MoshiProvider.providesMoshi().adapter(Event::class.java).toJsonValue(event) as? Map<*, *>
?: return false
val value = extractField(rawJson, key) ?: return false
//Patterns with no special glob characters should be treated as having asterisks prepended
// Patterns with no special glob characters should be treated as having asterisks prepended
// and appended when testing the condition.
try {
val modPattern = if (hasSpecialGlobChar(pattern)) simpleGlobToRegExp(pattern) else simpleGlobToRegExp("*$pattern*")
val regex = Regex(modPattern, RegexOption.DOT_MATCHES_ALL)
return regex.containsMatchIn(value)
} catch (e: Throwable) {
//e.g PatternSyntaxException
// e.g PatternSyntaxException
Timber.e(e, "Failed to evaluate push condition")
return false
}
}
private fun extractField(jsonObject: Map<*, *>, fieldPath: String): String? {
val fieldParts = fieldPath.split(".")
if (fieldParts.isEmpty()) return null
@ -77,9 +74,9 @@ class EventMatchCondition(val key: String, val pattern: String) : Condition(Kind
return glob.contains("*") || glob.contains("?")
}
//Very simple glob to regexp converter
// Very simple glob to regexp converter
private fun simpleGlobToRegExp(glob: String): String {
var out = ""//"^"
var out = "" // "^"
for (i in 0 until glob.length) {
val c = glob[i]
when (c) {
@ -90,7 +87,7 @@ class EventMatchCondition(val key: String, val pattern: String) : Condition(Kind
else -> out += c
}
}
out += ""//'$'.toString()
out += "" // '$'.toString()
return out
}
}

View File

@ -27,10 +27,10 @@ interface PushRuleService {
*/
fun fetchPushRules(scope: String = RuleScope.GLOBAL)
//TODO get push rule set
// TODO get push rule set
fun getPushRules(scope: String = RuleScope.GLOBAL): List<PushRule>
//TODO update rule
// TODO update rule
fun updatePushRuleEnableStatus(kind: RuleKind, pushRule: PushRule, enabled: Boolean, callback: MatrixCallback<Unit>): Cancelable

View File

@ -62,6 +62,5 @@ class RoomMemberCountCondition(val iz: String) : Condition(Kind.room_member_coun
Timber.d(t)
}
return null
}
}

View File

@ -18,7 +18,6 @@ package im.vector.matrix.android.api.pushrules
import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.room.model.PowerLevels
class SenderNotificationPermissionCondition(val key: String) : Condition(Kind.sender_notification_permission) {
override fun isSatisfied(conditionResolver: ConditionResolver): Boolean {
@ -29,7 +28,6 @@ class SenderNotificationPermissionCondition(val key: String) : Condition(Kind.se
return "User power level <$key>"
}
fun isSatisfied(event: Event, powerLevels: PowerLevels): Boolean {
return event.senderId != null && powerLevels.getUserPowerLevel(event.senderId) >= powerLevels.notificationLevel(key)
}

View File

@ -19,7 +19,6 @@ package im.vector.matrix.android.api.pushrules.rest
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class PushRule(
/**
@ -47,4 +46,3 @@ data class PushRule(
*/
val pattern: String? = null
)

View File

@ -68,7 +68,6 @@ interface Session :
val myUserId: String
get() = sessionParams.credentials.userId
/**
* This method allow to open a session. It does start some service on the background.
*/
@ -145,7 +144,5 @@ interface Session :
* A M_CONSENT_NOT_GIVEN error has been received from the homeserver
*/
fun onConsentNotGivenError(consentNotGivenError: ConsentNotGivenError)
}
}

View File

@ -27,5 +27,4 @@ interface CacheService {
* Clear the whole cached data, except credentials. Once done, the session is closed and has to be opened again
*/
fun clearCache(callback: MatrixCallback<Unit>)
}

View File

@ -40,5 +40,4 @@ data class ContentAttachmentData(
AUDIO,
VIDEO
}
}

View File

@ -112,5 +112,4 @@ interface CryptoService {
fun addNewSessionListener(newSessionListener: NewSessionListener)
fun removeSessionListener(listener: NewSessionListener)
}

View File

@ -210,5 +210,4 @@ interface KeysBackupService {
val isEnabled: Boolean
val isStucked: Boolean
val state: KeysBackupState
}

View File

@ -43,7 +43,7 @@ enum class SasVerificationTxState {
Verifying,
Verified,
//Global: The verification has been cancelled (by me or other), see cancelReason for details
// Global: The verification has been cancelled (by me or other), see cancelReason for details
Cancelled,
OnCancelled
}

View File

@ -34,7 +34,7 @@ import com.squareup.moshi.JsonClass
*/
@JsonClass(generateAdapter = true)
data class AggregatedAnnotation (
data class AggregatedAnnotation(
override val limited: Boolean? = false,
override val count: Int? = 0,
val chunk: List<RelationChunkInfo>? = null

View File

@ -81,7 +81,6 @@ data class Event(
@Json(name = "redacts") val redacts: String? = null
) {
@Transient
var mxDecryptionResult: OlmDecryptionResult? = null
@ -91,7 +90,6 @@ data class Event(
@Transient
var sendState: SendState = SendState.UNKNOWN
/**
* Check if event is a state event.
* @return true if event is state event.
@ -100,9 +98,9 @@ data class Event(
return EventType.isStateEvent(getClearType())
}
//==============================================================================================================
// ==============================================================================================================
// Crypto
//==============================================================================================================
// ==============================================================================================================
/**
* @return true if this event is encrypted.
@ -195,10 +193,8 @@ data class Event(
result = 31 * result + sendState.hashCode()
return result
}
}
fun Event.isTextMessage(): Boolean {
return getClearType() == EventType.MESSAGE
&& when (getClearContent()?.toModel<MessageContent>()?.type) {

View File

@ -16,7 +16,6 @@
package im.vector.matrix.android.api.session.events.model
/**
* Constants defining known event types from Matrix specifications.
*/
@ -93,7 +92,6 @@ object EventType {
STATE_PINNED_EVENT
)
fun isStateEvent(type: String): Boolean {
return STATE_EVENTS.contains(type)
}

View File

@ -15,7 +15,6 @@
*/
package im.vector.matrix.android.api.session.events.model
/**
* Constants defining known event relation types from Matrix specifications
*/
@ -27,5 +26,4 @@ object RelationType {
const val REPLACE = "m.replace"
/** Lets you define an event which references an existing event.*/
const val REFERENCE = "m.reference"
}

View File

@ -15,7 +15,6 @@
*/
package im.vector.matrix.android.api.session.events.model
interface UnsignedRelationInfo {
val limited : Boolean?
val count: Int?

View File

@ -20,7 +20,6 @@ import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.internal.crypto.attachments.ElementToDecrypt
import java.io.File
/**
* This interface defines methods to get files.
*/

View File

@ -19,7 +19,6 @@ package im.vector.matrix.android.api.session.group
import androidx.lifecycle.LiveData
import im.vector.matrix.android.api.session.group.model.GroupSummary
/**
* This interface defines methods to get groups. It's implemented at the session level.
*/

View File

@ -25,5 +25,4 @@ interface HomeServerCapabilitiesService {
* Get the HomeServer capabilities
*/
fun getHomeServerCapabilities(): HomeServerCapabilities
}

View File

@ -19,7 +19,6 @@ import androidx.lifecycle.LiveData
import im.vector.matrix.android.api.MatrixCallback
import java.util.UUID
interface PushersService {
/**
@ -53,7 +52,6 @@ interface PushersService {
append: Boolean,
withEventIdOnly: Boolean): UUID
fun removeHttpPusher(pushkey: String, appId: String, callback: MatrixCallback<Unit>)
companion object {

View File

@ -53,5 +53,4 @@ interface Room :
fun getRoomSummaryLive(): LiveData<Optional<RoomSummary>>
fun roomSummary(): RoomSummary?
}

View File

@ -42,5 +42,4 @@ interface RoomDirectoryService {
* Includes both the available protocols and all fields required for queries against each protocol.
*/
fun getThirdPartyProtocol(callback: MatrixCallback<Map<String, ThirdPartyProtocol>>): Cancelable
}

View File

@ -53,5 +53,4 @@ interface RoomService {
* @return the [LiveData] of [RoomSummary]
*/
fun liveRoomSummaries(): LiveData<List<RoomSummary>>
}

View File

@ -21,5 +21,4 @@ import im.vector.matrix.android.api.failure.Failure
sealed class CreateRoomFailure : Failure.FeatureFailure() {
object CreatedWithTimeout: CreateRoomFailure()
}

View File

@ -21,5 +21,4 @@ import im.vector.matrix.android.api.failure.Failure
sealed class JoinRoomFailure : Failure.FeatureFailure() {
object JoinedWithTimeout : JoinRoomFailure()
}

View File

@ -64,5 +64,4 @@ interface MembershipService {
* Leave the room, or reject an invitation.
*/
fun leave(callback: MatrixCallback<Unit>): Cancelable
}

View File

@ -43,5 +43,4 @@ enum class Membership(val value: String) {
fun isLeft(): Boolean {
return this == KNOCK || this == LEAVE || this == BAN
}
}

View File

@ -78,7 +78,6 @@ data class PowerLevels(
return if (!TextUtils.isEmpty(eventTypeString) && !TextUtils.isEmpty(userId)) {
getUserPowerLevel(userId) >= minimumPowerLevelForSendingEventAsMessage(eventTypeString)
} else false
}
/**
@ -113,7 +112,6 @@ data class PowerLevels(
return events[eventTypeString] ?: stateDefault
}
/**
* Get the notification level for a dedicated key.
*

View File

@ -48,4 +48,3 @@ data class RoomSummary(
val hasNewMessages: Boolean
get() = notificationCount != 0
}

View File

@ -31,5 +31,4 @@ data class CallAnswerContent(
@Json(name = "type") val type: String,
@Json(name = "sdp") val sdp: String
)
}

View File

@ -32,5 +32,4 @@ data class CallCandidatesContent(
@Json(name = "sdpMLineIndex") val sdpMLineIndex: String,
@Json(name = "candidate") val candidate: String
)
}

View File

@ -37,6 +37,5 @@ data class CallInviteContent(
}
}
fun isVideo(): Boolean = offer.sdp.contains(Offer.SDP_VIDEO)
}

View File

@ -28,5 +28,3 @@ data class RoomCreateContent(
@Json(name = "room_version") val roomVersion: String? = null,
@Json(name = "predecessor") val predecessor: Predecessor? = null
)

View File

@ -19,7 +19,6 @@ package im.vector.matrix.android.api.session.room.model.message
import im.vector.matrix.android.api.session.events.model.Content
import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent
interface MessageContent {
val type: String
val body: String
@ -27,7 +26,6 @@ interface MessageContent {
val newContent: Content?
}
fun MessageContent?.isReply(): Boolean {
return this?.relatesTo?.inReplyTo?.eventId != null
}

View File

@ -18,7 +18,6 @@ package im.vector.matrix.android.api.session.room.model.message
import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo
/**
* Interface for message which can contains an encrypted file
*/

View File

@ -24,6 +24,6 @@ data class ReactionInfo(
@Json(name = "rel_type") override val type: String?,
@Json(name = "event_id") override val eventId: String,
val key: String,
//always null for reaction
// always null for reaction
@Json(name = "m.in_reply_to") override val inReplyTo: ReplyToContent? = null
) : RelationContent

View File

@ -48,7 +48,6 @@ import im.vector.matrix.android.api.util.Optional
*/
interface RelationService {
/**
* Sends a reaction (emoji) to the targetedEvent.
* @param reaction the reaction (preferably emoji)
@ -57,7 +56,6 @@ interface RelationService {
fun sendReaction(reaction: String,
targetEventId: String): Cancelable
/**
* Undo a reaction (emoji) to the targetedEvent.
* @param reaction the reaction (preferably emoji)
@ -66,8 +64,7 @@ interface RelationService {
*/
fun undoReaction(reaction: String,
targetEventId: String,
myUserId: String)//: Cancelable
myUserId: String) // : Cancelable
/**
* Edit a text message body. Limited to "m.text" contentType
@ -81,7 +78,6 @@ interface RelationService {
newBodyAutoMarkdown: Boolean,
compatibilityBodyText: String = "* $newBodyText"): Cancelable
/**
* Edit a reply. This is a special case because replies contains fallback text as a prefix.
* This method will take the new body (stripped from fallbacks) and re-add them before sending.
@ -100,7 +96,6 @@ interface RelationService {
*/
fun fetchEditHistory(eventId: String, callback: MatrixCallback<List<Event>>)
/**
* Reply to an event in the timeline (must be in same room)
* https://matrix.org/docs/spec/client_server/r0.4.0.html#id350
@ -113,6 +108,4 @@ interface RelationService {
autoMarkdown: Boolean = false): Cancelable?
fun getEventSummaryLive(eventId: String): LiveData<Optional<EventAnnotationsSummary>>
}

View File

@ -27,5 +27,4 @@ data class RoomTag(
val ROOM_TAG_NO_TAG = "m.recent"
val ROOM_TAG_SERVER_NOTICE = "m.server_notice"
}
}

View File

@ -51,5 +51,4 @@ data class RoomDirectoryData(
companion object {
const val DEFAULT_HOME_SERVER_NAME = "Matrix"
}
}

View File

@ -51,7 +51,6 @@ data class ThirdPartyProtocolInstance(
@Json(name = "instance_id")
var instanceId: String? = null,
/**
* FIXDOC Not documented on matrix.org doc
*/

View File

@ -35,5 +35,4 @@ interface DraftService {
* The draft list can contain one draft for {regular, reply, quote} and an arbitrary number of {edit} drafts
*/
fun getDraftsLive(): LiveData<List<UserDraft>>
}

View File

@ -22,7 +22,6 @@ import im.vector.matrix.android.api.session.room.model.message.MessageType
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.matrix.android.api.util.Cancelable
/**
* This interface defines methods to send events in a room. It's implemented at the room level.
*/
@ -66,7 +65,6 @@ interface SendService {
*/
fun redactEvent(event: Event, reason: String?): Cancelable
/**
* Schedule this message to be resent
* @param localEcho the unsent local echo
@ -79,7 +77,6 @@ interface SendService {
*/
fun resendMediaMessage(localEcho: TimelineEvent): Cancelable?
/**
* Remove this failed message from the timeline
* @param localEcho the unsent local echo
@ -92,5 +89,4 @@ interface SendService {
* Resend all failed messages one by one (and keep order)
*/
fun resendAllFailedMessages()
}

View File

@ -16,7 +16,6 @@
package im.vector.matrix.android.api.session.room.send
enum class SendState {
UNKNOWN,
// the event has not been sent
@ -46,7 +45,4 @@ enum class SendState {
fun hasFailed() = HAS_FAILED_STATES.contains(this)
fun isSending() = IS_SENDING_STATES.contains(this)
}

View File

@ -27,5 +27,4 @@ interface StateService {
fun updateTopic(topic: String, callback: MatrixCallback<Unit>)
fun getStateEvent(eventType: String): Event?
}

View File

@ -50,7 +50,6 @@ interface Timeline {
*/
fun restartWithEventId(eventId: String?)
/**
* Check if the timeline can be enriched by paginating.
* @param the direction to check in
@ -58,7 +57,6 @@ interface Timeline {
*/
fun hasMoreToLoad(direction: Direction): Boolean
/**
* This is the main method to enrich the timeline with new data.
* It will call the onUpdated method from [Listener] when the data will be processed.
@ -97,7 +95,6 @@ interface Timeline {
*/
fun getFirstDisplayableEventId(eventId: String): String?
interface Listener {
/**
* Call when the timeline has been updated through pagination or sync.
@ -119,5 +116,4 @@ interface Timeline {
*/
BACKWARDS
}
}

View File

@ -88,7 +88,6 @@ data class TimelineEvent(
}
}
/**
* Tells if the event has been edited
*/
@ -107,7 +106,6 @@ fun TimelineEvent.getEditedEventId(): String? {
fun TimelineEvent.getLastMessageContent(): MessageContent? = annotations?.editSummary?.aggregatedContent?.toModel()
?: root.getClearContent().toModel()
/**
* Get last Message body, after a possible edition
*/
@ -121,7 +119,6 @@ fun TimelineEvent.getLastMessageBody(): String? {
return null
}
fun TimelineEvent.getTextEditableContent(): String? {
val originalContent = root.getClearContent().toModel<MessageContent>() ?: return null
val isReply = originalContent.isReply() || root.content.toModel<EncryptedEventContent>()?.relatesTo?.inReplyTo?.eventId != null

View File

@ -33,9 +33,7 @@ interface TimelineService {
*/
fun createTimeline(eventId: String?, settings: TimelineSettings): Timeline
fun getTimeLineEvent(eventId: String): TimelineEvent?
fun getTimeLineEventLive(eventId: String): LiveData<Optional<TimelineEvent>>
}

View File

@ -24,5 +24,4 @@ interface SecureStorageService {
fun securelyStoreObject(any: Any, keyAlias: String, outputStream: OutputStream)
fun <T> loadSecureSecret(inputStream: InputStream, keyAlias: String): T?
}

View File

@ -27,5 +27,4 @@ interface SignOutService {
* Sign out
*/
fun signOut(callback: MatrixCallback<Unit>)
}

View File

@ -64,5 +64,4 @@ interface UserService {
* @return a Livedata of users
*/
fun livePagedUsers(filter: String? = null): LiveData<PagedList<User>>
}

View File

@ -26,7 +26,6 @@ interface Cancelable {
* The cancel method, it does nothing by default.
*/
fun cancel() {
//no-op
// no-op
}
}

View File

@ -15,7 +15,6 @@
*/
package im.vector.matrix.android.api.util
object ContentUtils {
fun extractUsefulTextFromReply(repliedBody: String): String {
val lines = repliedBody.lines()

View File

@ -31,7 +31,7 @@ data class Optional<T : Any> constructor(private val value: T?) {
return value ?: fn()
}
fun hasValue(): Boolean{
fun hasValue(): Boolean {
return value != null
}
@ -40,7 +40,6 @@ data class Optional<T : Any> constructor(private val value: T?) {
return Optional(value)
}
}
}
fun <T : Any> T?.toOptional() = Optional(this)

View File

@ -47,5 +47,4 @@ internal interface AuthAPI {
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
fun login(@Body loginParams: PasswordLoginParams): Call<Credentials>
}

View File

@ -55,11 +55,9 @@ internal abstract class AuthModule {
}
}
@Binds
abstract fun bindSessionParamsStore(sessionParamsStore: RealmSessionParamsStore): SessionParamsStore
@Binds
abstract fun bindAuthenticator(authenticator: DefaultAuthenticator): Authenticator
}

View File

@ -123,6 +123,4 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
val retrofit = retrofitFactory.create(okHttpClient.get(), homeServerConnectionConfig.homeServerUri.toString())
return retrofit.create(AuthAPI::class.java)
}
}

View File

@ -26,7 +26,6 @@ internal data class PasswordLoginParams(@Json(name = "identifier") val identifie
@Json(name = "initial_device_display_name") val deviceDisplayName: String?,
@Json(name = "device_id") val deviceId: String?) : LoginParams {
companion object {
val IDENTIFIER_KEY_TYPE_USER = "m.id.user"
@ -40,7 +39,6 @@ internal data class PasswordLoginParams(@Json(name = "identifier") val identifie
val IDENTIFIER_KEY_COUNTRY = "country"
val IDENTIFIER_KEY_NUMBER = "number"
fun userIdentifier(user: String,
password: String,
deviceDisplayName: String? = null,
@ -49,7 +47,6 @@ internal data class PasswordLoginParams(@Json(name = "identifier") val identifie
identifier[IDENTIFIER_KEY_TYPE] = IDENTIFIER_KEY_TYPE_USER
identifier[IDENTIFIER_KEY_USER] = user
return PasswordLoginParams(identifier, password, LoginFlowTypes.PASSWORD, deviceDisplayName, deviceId)
}
fun thirdPartyIdentifier(medium: String,
@ -62,7 +59,6 @@ internal data class PasswordLoginParams(@Json(name = "identifier") val identifie
identifier[IDENTIFIER_KEY_MEDIUM] = medium
identifier[IDENTIFIER_KEY_ADDRESS] = address
return PasswordLoginParams(identifier, password, LoginFlowTypes.PASSWORD, deviceDisplayName, deviceId)
}
}
}

View File

@ -99,5 +99,4 @@ internal class RealmSessionParamsStore @Inject constructor(private val mapper: S
realm.close()
}
}
}

View File

@ -50,6 +50,4 @@ internal class SessionParamsMapper @Inject constructor(moshi: Moshi) {
}
return SessionParamsEntity(sessionParams.credentials.userId, credentialsJson, homeServerConnectionConfigJson)
}
}

View File

@ -74,7 +74,6 @@ internal abstract class CryptoModule {
return RealmClearCacheTask(realmConfiguration)
}
@JvmStatic
@Provides
fun providesCryptoStore(@CryptoDatabase
@ -104,7 +103,6 @@ internal abstract class CryptoModule {
fun providesCryptoConfig(): MXCryptoConfig {
return MXCryptoConfig()
}
}
@Binds

View File

@ -398,7 +398,6 @@ internal class DefaultCryptoService @Inject constructor(
}
}
callback?.onSuccess(Unit)
}
@ -438,7 +437,7 @@ internal class DefaultCryptoService @Inject constructor(
val encryptingClass = MXCryptoAlgorithms.hasEncryptorClassForAlgorithm(algorithm)
if (!encryptingClass) {
Timber.e("## setEncryptionInRoom() : Unable to encrypt room ${roomId} with $algorithm")
Timber.e("## setEncryptionInRoom() : Unable to encrypt room $roomId with $algorithm")
return false
}
@ -651,7 +650,7 @@ internal class DefaultCryptoService @Inject constructor(
incomingRoomKeyRequestManager.onRoomKeyRequestEvent(event)
}
else -> {
//ignore
// ignore
}
}
}
@ -706,7 +705,6 @@ internal class DefaultCryptoService @Inject constructor(
} else {
RoomMembers(realm, roomId).getJoinedRoomMemberIds()
}
}
return userIds
}
@ -753,7 +751,6 @@ internal class DefaultCryptoService @Inject constructor(
}
}
/**
* Upload my user's device keys.
*/
@ -937,7 +934,6 @@ internal class DefaultCryptoService @Inject constructor(
cryptoStore.setRoomsListBlacklistUnverifiedDevices(roomIds)
}
/**
* Add this room to the ones which don't encrypt messages to unverified devices.
*

View File

@ -74,7 +74,6 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
} catch (e: Exception) {
Timber.e(e, "## canRetryKeysDownload() failed")
}
}
return res

View File

@ -17,7 +17,6 @@
package im.vector.matrix.android.internal.crypto
import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyRequestBody
@ -77,4 +76,3 @@ open class IncomingRoomKeyRequest {
*/
constructor()
}

View File

@ -35,7 +35,6 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
private val cryptoStore: IMXCryptoStore,
private val roomDecryptorProvider: RoomDecryptorProvider) {
// list of IncomingRoomKeyRequests/IncomingRoomKeyRequestCancellations
// we received in the current sync.
private val receivedRoomKeyRequests = ArrayList<IncomingRoomKeyRequest>()
@ -166,12 +165,10 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## onRoomKeyRequest() failed")
}
}
}
}
/**
* A room key request cancellation has been received.
*
@ -185,7 +182,6 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## onRoomKeyRequestCancellation() failed")
}
}
}
}
@ -201,5 +197,4 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
roomKeysRequestListeners.remove(listener)
}
}
}

View File

@ -94,7 +94,6 @@ internal class MXOlmDevice @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "MXOlmDevice : cannot initialize olmAccount")
}
} else {
Timber.v("MXOlmDevice : use an existing account")
}
@ -217,7 +216,6 @@ internal class MXOlmDevice @Inject constructor(
Timber.v("## createOutboundSession() ; olmSession.sessionIdentifier: $sessionIdentifier")
return sessionIdentifier
} catch (e: Exception) {
Timber.e(e, "## createOutboundSession() failed")
@ -343,7 +341,7 @@ internal class MXOlmDevice @Inject constructor(
if (olmSessionWrapper != null) {
try {
Timber.v("## encryptMessage() : olmSession.sessionIdentifier: $sessionId")
//Timber.v("## encryptMessage() : payloadString: " + payloadString);
// Timber.v("## encryptMessage() : payloadString: " + payloadString);
olmMessage = olmSessionWrapper.olmSession.encryptMessage(payloadString)
store.storeSession(olmSessionWrapper, theirDeviceIdentityKey)
@ -354,7 +352,6 @@ internal class MXOlmDevice @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## encryptMessage() : failed")
}
}
return res
@ -386,7 +383,6 @@ internal class MXOlmDevice @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## decryptMessage() : decryptMessage failed")
}
}
return payloadString
@ -410,7 +406,6 @@ internal class MXOlmDevice @Inject constructor(
return null != olmSessionWrapper && olmSessionWrapper.olmSession.matchesInboundSession(ciphertext)
}
// Outbound group session
/**
@ -446,7 +441,6 @@ internal class MXOlmDevice @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## getSessionKey() : failed")
}
}
return null
}
@ -477,7 +471,6 @@ internal class MXOlmDevice @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "## encryptGroupMessage() : failed")
}
}
return null
}
@ -513,7 +506,7 @@ internal class MXOlmDevice @Inject constructor(
val existingFirstKnown = it.firstKnownIndex!!
val newKnownFirstIndex = session.firstKnownIndex
//If our existing session is better we keep it
// If our existing session is better we keep it
if (newKnownFirstIndex != null && existingFirstKnown <= newKnownFirstIndex) {
session.olmInboundGroupSession?.releaseSession()
return false
@ -601,7 +594,7 @@ internal class MXOlmDevice @Inject constructor(
// For now we just ignore updates. TODO: implement something here
if (it.firstKnownIndex!! <= session.firstKnownIndex!!) {
//Ignore this, keep existing
// Ignore this, keep existing
session.olmInboundGroupSession!!.releaseSession()
} else {
sessions.add(session)
@ -746,7 +739,6 @@ internal class MXOlmDevice @Inject constructor(
return if (theirDeviceIdentityKey.isEmpty() || sessionId.isEmpty()) null else {
store.getDeviceSession(sessionId, theirDeviceIdentityKey)
}
}
/**

View File

@ -15,7 +15,6 @@
*/
package im.vector.matrix.android.internal.crypto
interface NewSessionListener {
fun onNewSession(roomId: String?, senderKey: String, sessionId: String)
}

View File

@ -42,13 +42,11 @@ internal class ObjectSigner @Inject constructor(private val credentials: Credent
val content = HashMap<String, String>()
content["ed25519:" + credentials.deviceId] = olmDevice.signMessage(strToSign)
?: "" //null reported by rageshake if happens during logout
?: "" // null reported by rageshake if happens during logout
result[credentials.userId] = content
return result
}
}

View File

@ -53,7 +53,6 @@ internal class OneTimeKeysUploader @Inject constructor(
oneTimeKeyCount = currentCount
}
/**
* Check if the OTK must be uploaded.
*/

View File

@ -116,4 +116,3 @@ class OutgoingRoomKeyRequest(
}
}
}

View File

@ -90,7 +90,6 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
val req = cryptoStore.getOrAddOutgoingRoomKeyRequest(
OutgoingRoomKeyRequest(requestBody, recipients, makeTxnId(), OutgoingRoomKeyRequest.RequestState.UNSENT))
if (req?.state == OutgoingRoomKeyRequest.RequestState.UNSENT) {
startTimer()
}
@ -154,7 +153,6 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
}
}
/**
* Start the background timer to send queued requests, if the timer isn't already running.
*/
@ -261,7 +259,6 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
startTimer()
}
override fun onSuccess(data: Unit) {
Timber.v("## sendOutgoingRoomKeyRequestCancellation() : done")
val resend = request.state === OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING_AND_WILL_RESEND
@ -312,6 +309,5 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
private const val SEND_KEY_REQUESTS_DELAY_MS = 500
private val BACKGROUND_HANDLER = createBackgroundHandler("OutgoingRoomKeyRequest")
}
}

View File

@ -82,7 +82,6 @@ internal class RoomDecryptorProvider @Inject constructor(
try {
it.onNewSession(roomId, senderKey, sessionId)
} catch (e: Throwable) {
}
}
}

View File

@ -30,7 +30,6 @@ import javax.inject.Inject
internal class EnsureOlmSessionsForDevicesAction @Inject constructor(private val olmDevice: MXOlmDevice,
private val oneTimeKeysForUsersDeviceTask: ClaimOneTimeKeysForUsersDeviceTask) {
suspend fun handle(devicesByUser: Map<String, List<MXDeviceInfo>>): MXUsersDevicesMap<MXOlmSessionResult> {
val devicesWithoutSession = ArrayList<MXDeviceInfo>()
@ -149,5 +148,4 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(private val
return sessionId
}
}

View File

@ -93,5 +93,4 @@ internal class MessageEncrypter @Inject constructor(private val credentials: Cre
return res
}
}

View File

@ -129,7 +129,6 @@ internal class MXMegolmDecryption(private val userId: String,
)
}
/**
* Helper for the real decryptEvent and for _retryDecryption. If
* requestKeysOnFail is true, we'll send an m.room_key_request when we fail
@ -177,7 +176,6 @@ internal class MXMegolmDecryption(private val userId: String,
val encryptedEventContent = event.content.toModel<EncryptedEventContent>() ?: return
val pendingEventsKey = "${encryptedEventContent.senderKey}|${encryptedEventContent.sessionId}"
if (!pendingEvents.containsKey(pendingEventsKey)) {
pendingEvents[pendingEventsKey] = HashMap()
}
@ -352,4 +350,3 @@ internal class MXMegolmDecryption(private val userId: String,
}
}
}

Some files were not shown because too many files have changed in this diff Show More