Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fre/start_dm_on_first_msg
Browse files Browse the repository at this point in the history
* develop: (156 commits)
  adding test case for showing html entities are processed
  adding tests around the event html rendering - the test helper is a little hacky in order to covert the spans to something human readable
  removing extra line
  adding changelog entry
  overriding the default list handler with an implementation that takes into account the initial starting position
  trigger CI
  Use executeTransactionAwait (need realm refresh in this case)
  Bump flipper from 0.152.0 to 0.153.0
  Use executeTransactionAwait (need realm refresh in this case)
  generating 1.4.27 changelog and updating version
  Fixing crash when sharing plain text, such as a url
  Fix crashes when opening Thread (#6463)
  Timeline: fix validation of timeline event changes
  Fix ConcurrentModificationException on BackgroundDetectionObserver
  Fix crashes when opening Thread (#6463)
  suppressing unused string resource
  Changelog
  Fix ConcurrentModificationException on BackgroundDetectionObserver
  Fix typo
  adding changelog entry
  ...
Florian Renaud committed Jul 11, 2022

Verified

This commit was signed with the committer’s verified signature.
germa89 German
2 parents 414dc52 + 5a37838 commit 68bd55f
Showing 209 changed files with 4,860 additions and 1,154 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Changes in Element v1.4.27 (2022-07-06)
=======================================

Bugfixes 🐛
----------
- Fixes crash when sharing plain text, such as a url ([#6451](https://github.com/vector-im/element-android/issues/6451))
- Fix crashes on Timeline [Thread] due to range validation ([#6461](https://github.com/vector-im/element-android/issues/6461))
- Fix crashes when opening Thread ([#6463](https://github.com/vector-im/element-android/issues/6463))
- Fix ConcurrentModificationException on BackgroundDetectionObserver ([#6469](https://github.com/vector-im/element-android/issues/6469))


Changes in Element v1.4.26 (2022-06-30)
=======================================

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ buildscript {
classpath libs.gradle.gradlePlugin
classpath libs.gradle.kotlinPlugin
classpath libs.gradle.hiltPlugin
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.gms:google-services:4.3.13'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
classpath "com.likethesalad.android:stem-plugin:2.1.1"
1 change: 1 addition & 0 deletions changelog.d/4777.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes numbered lists always starting from 1
1 change: 1 addition & 0 deletions changelog.d/5398.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds LoginType to SessionParams to fix soft logout form not showing for SSO and Password type
1 change: 1 addition & 0 deletions changelog.d/5853.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve user experience when he is first invited to a room. Users will be able to decrypt and view previous messages
1 change: 1 addition & 0 deletions changelog.d/6401.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Location sharing] - Reply action on a live message
1 change: 1 addition & 0 deletions changelog.d/6423.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Poll] - Add a description under undisclosed poll when not ended
1 change: 1 addition & 0 deletions changelog.d/6430.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Poll] Fixes visible and wrong votes in closed poll after removing 2 previous polls
1 change: 1 addition & 0 deletions changelog.d/6434.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add code check to prevent modification of frozen class
1 change: 1 addition & 0 deletions changelog.d/6436.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Let your Activity or Fragment implement `VectorMenuProvider` if they provide a menu.
1 change: 1 addition & 0 deletions changelog.d/6442.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix HTML entities being displayed in messages
1 change: 1 addition & 0 deletions changelog.d/6450.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gallery picker can pick external images
1 change: 1 addition & 0 deletions changelog.d/6451.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes crash when sharing plain text, such as a url
1 change: 1 addition & 0 deletions changelog.d/6458.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename Android Service to use `AndroidService` suffix
1 change: 1 addition & 0 deletions changelog.d/6461.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crashes on Timeline [Thread] due to range validation
1 change: 1 addition & 0 deletions changelog.d/6463.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crashes when opening Thread
1 change: 1 addition & 0 deletions changelog.d/6469.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ConcurrentModificationException on BackgroundDetectionObserver
1 change: 1 addition & 0 deletions coverage.gradle
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ def excludes = [
'**/*Activity*',
'**/*Fragment*',
'**/*Application*',
'**/*AndroidService*',

// We would like to exclude android widgets as well but our naming is inconsistent

8 changes: 4 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -19,17 +19,17 @@ def retrofit = "2.9.0"
def arrow = "0.8.2"
def markwon = "4.6.2"
def moshi = "1.13.0"
def lifecycle = "2.4.1"
def lifecycle = "2.5.0"
def flowBinding = "1.2.0"
def flipper = "0.151.1"
def flipper = "0.153.0"
def epoxy = "4.6.2"
def mavericks = "2.7.0"
def glide = "4.13.2"
def bigImageViewer = "1.8.1"
def jjwt = "0.11.5"
def vanniktechEmoji = "0.15.0"

def fragment = "1.4.1"
def fragment = "1.5.0"

// Testing
def mockk = "1.12.3" // We need to use 1.12.3 to have mocking in androidTest until a new version is released: https://github.com/mockk/mockk/issues/819
@@ -50,7 +50,7 @@ ext.libs = [
],
androidx : [
'annotation' : "androidx.annotation:annotation:1.4.0",
'activity' : "androidx.activity:activity:1.4.0",
'activity' : "androidx.activity:activity:1.5.0",
'annotations' : "androidx.annotation:annotation:1.3.0",
'appCompat' : "androidx.appcompat:appcompat:1.4.2",
'biometric' : "androidx.biometric:biometric:1.1.0",
2 changes: 1 addition & 1 deletion docs/pull_request.md
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ Examples of prefixes:
- `[Bugfix]`
- etc.

Also, it's still possible to add labels to the PRs, such as `A-` or `T-` labels, even if this is not a string requirement. We prefer to spend time to add labels on issues.
Also, it's still possible to add labels to the PRs, such as `A-` or `T-` labels, even if this is not a strong requirement. We prefer to spend time to add labels on issues.

##### PR description

2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/40104270.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Main changes in this version: Various bug fixes and stability improvements.
Full changelog: https://github.com/vector-im/element-android/releases
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ class MediaPicker : Picker<MultiPickerBaseMediaType>() {
return Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, !single)
type = "video/*, image/*"
type = "*/*"
val mimeTypes = arrayOf("image/*", "video/*")
putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
}
1 change: 1 addition & 0 deletions library/ui-styles/build.gradle
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ android {

dependencies {
implementation libs.androidx.appCompat
implementation libs.androidx.fragmentKtx
implementation libs.google.material
// Pref theme
implementation libs.androidx.preferenceKtx
Original file line number Diff line number Diff line change
@@ -18,8 +18,12 @@ package im.vector.lib.ui.styles.debug

import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import im.vector.lib.ui.styles.R
@@ -31,6 +35,7 @@ abstract class DebugMaterialThemeActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupMenu()
val views = ActivityDebugMaterialThemeBinding.inflate(layoutInflater)
setContentView(views.root)

@@ -72,6 +77,27 @@ abstract class DebugMaterialThemeActivity : AppCompatActivity() {
}
}

private fun setupMenu() {
addMenuProvider(
object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.menu_debug, menu)
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
Toast.makeText(
this@DebugMaterialThemeActivity,
"Menu ${menuItem.title} clicked!",
Toast.LENGTH_SHORT
).show()
return true
}
},
this,
Lifecycle.State.RESUMED
)
}

private fun showTestDialog(theme: Int) {
MaterialAlertDialogBuilder(this, theme)
.setTitle("Dialog title")
@@ -82,9 +108,4 @@ abstract class DebugMaterialThemeActivity : AppCompatActivity() {
.setNeutralButton("Neutral", null)
.show()
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_debug, menu)
return true
}
}
Original file line number Diff line number Diff line change
@@ -18,12 +18,15 @@ package org.matrix.android.sdk.common

import android.content.Context
import android.net.Uri
import android.util.Log
import androidx.lifecycle.Observer
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
@@ -38,7 +41,10 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationResult
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.getRoomSummary
import org.matrix.android.sdk.api.session.room.Room
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.api.session.room.timeline.Timeline
@@ -47,14 +53,15 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.api.session.sync.SyncState
import timber.log.Timber
import java.util.UUID
import java.util.concurrent.CancellationException
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

/**
* This class exposes methods to be used in common cases
* Registration, login, Sync, Sending messages...
*/
class CommonTestHelper private constructor(context: Context) {
class CommonTestHelper internal constructor(context: Context) {

companion object {
internal fun runSessionTest(context: Context, autoSignoutOnClose: Boolean = true, block: (CommonTestHelper) -> Unit) {
@@ -241,6 +248,37 @@ class CommonTestHelper private constructor(context: Context) {
return sentEvents
}

fun waitForAndAcceptInviteInRoom(otherSession: Session, roomID: String) {
waitWithLatch { latch ->
retryPeriodicallyWithLatch(latch) {
val roomSummary = otherSession.getRoomSummary(roomID)
(roomSummary != null && roomSummary.membership == Membership.INVITE).also {
if (it) {
Log.v("# TEST", "${otherSession.myUserId} can see the invite")
}
}
}
}

// not sure why it's taking so long :/
runBlockingTest(90_000) {
Log.v("#E2E TEST", "${otherSession.myUserId} tries to join room $roomID")
try {
otherSession.roomService().joinRoom(roomID)
} catch (ex: JoinRoomFailure.JoinedWithTimeout) {
// it's ok we will wait after
}
}

Log.v("#E2E TEST", "${otherSession.myUserId} waiting for join echo ...")
waitWithLatch {
retryPeriodicallyWithLatch(it) {
val roomSummary = otherSession.getRoomSummary(roomID)
roomSummary != null && roomSummary.membership == Membership.JOIN
}
}
}

/**
* Reply in a thread
* @param room the room where to send the messages
@@ -285,6 +323,8 @@ class CommonTestHelper private constructor(context: Context) {
)
assertNotNull(session)
return session.also {
// most of the test was created pre-MSC3061 so ensure compatibility
it.cryptoService().enableShareKeyOnInvite(false)
trackedSessions.add(session)
}
}
@@ -428,16 +468,26 @@ class CommonTestHelper private constructor(context: Context) {
* @param latch
* @throws InterruptedException
*/
fun await(latch: CountDownLatch, timeout: Long? = TestConstants.timeOutMillis) {
fun await(latch: CountDownLatch, timeout: Long? = TestConstants.timeOutMillis, job: Job? = null) {
assertTrue(
"Timed out after " + timeout + "ms waiting for something to happen. See stacktrace for cause.",
latch.await(timeout ?: TestConstants.timeOutMillis, TimeUnit.MILLISECONDS)
latch.await(timeout ?: TestConstants.timeOutMillis, TimeUnit.MILLISECONDS).also {
if (!it) {
// cancel job on timeout
job?.cancel("Await timeout")
}
}
)
}

suspend fun retryPeriodicallyWithLatch(latch: CountDownLatch, condition: (() -> Boolean)) {
while (true) {
delay(1000)
try {
delay(1000)
} catch (ex: CancellationException) {
// the job was canceled, just stop
return
}
if (condition()) {
latch.countDown()
return
@@ -447,10 +497,10 @@ class CommonTestHelper private constructor(context: Context) {

fun waitWithLatch(timeout: Long? = TestConstants.timeOutMillis, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend (CountDownLatch) -> Unit) {
val latch = CountDownLatch(1)
coroutineScope.launch(dispatcher) {
val job = coroutineScope.launch(dispatcher) {
block(latch)
}
await(latch, timeout)
await(latch, timeout, job)
}

fun <T> runBlockingTest(timeout: Long = TestConstants.timeOutMillis, block: suspend () -> T): T {
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.getRoom
import org.matrix.android.sdk.api.session.room.Room
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
@@ -76,11 +77,14 @@ class CryptoTestHelper(val testHelper: CommonTestHelper) {
/**
* @return alice session
*/
fun doE2ETestWithAliceInARoom(encryptedRoom: Boolean = true): CryptoTestData {
fun doE2ETestWithAliceInARoom(encryptedRoom: Boolean = true, roomHistoryVisibility: RoomHistoryVisibility? = null): CryptoTestData {
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, defaultSessionParams)

val roomId = testHelper.runBlockingTest {
aliceSession.roomService().createRoom(CreateRoomParams().apply { name = "MyRoom" })
aliceSession.roomService().createRoom(CreateRoomParams().apply {
historyVisibility = roomHistoryVisibility
name = "MyRoom"
})
}
if (encryptedRoom) {
testHelper.waitWithLatch { latch ->
@@ -104,8 +108,8 @@ class CryptoTestHelper(val testHelper: CommonTestHelper) {
/**
* @return alice and bob sessions
*/
fun doE2ETestWithAliceAndBobInARoom(encryptedRoom: Boolean = true): CryptoTestData {
val cryptoTestData = doE2ETestWithAliceInARoom(encryptedRoom)
fun doE2ETestWithAliceAndBobInARoom(encryptedRoom: Boolean = true, roomHistoryVisibility: RoomHistoryVisibility? = null): CryptoTestData {
val cryptoTestData = doE2ETestWithAliceInARoom(encryptedRoom, roomHistoryVisibility)
val aliceSession = cryptoTestData.firstSession
val aliceRoomId = cryptoTestData.roomId

Loading

0 comments on commit 68bd55f

Please sign in to comment.