Android 6: App crash when read Contact permission is granted (#2064)

This commit is contained in:
Benoit Marty 2020-09-06 00:58:00 +02:00
parent 751c870a4a
commit be9a91e3fe
4 changed files with 28 additions and 3 deletions

View File

@ -26,6 +26,7 @@ Bugfix 🐛:
- Login with Matrix-Id | Autodiscovery fails if identity server is invalid and Homeserver ok (#2027)
- Support for image compression on Android 10
- Verification popup won't show
- Android 6: App crash when read Contact permission is granted (#2064)
Translations 🗣:
- The SDK is now using SAS string translations from [Weblate Matrix-doc project](https://translate.riot.im/projects/matrix-doc/) (#1909)

View File

@ -345,6 +345,14 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector {
}
}
protected var postResumeScheduledAction: Runnable? = null
override fun onPostResume() {
super.onPostResume()
postResumeScheduledAction?.run()
postResumeScheduledAction = null
}
override fun onPause() {
super.onPause()
Timber.i("onPause Activity ${this.javaClass.simpleName}")

View File

@ -49,8 +49,10 @@ import im.vector.app.features.userdirectory.UserDirectorySharedAction
import im.vector.app.features.userdirectory.UserDirectorySharedActionViewModel
import im.vector.app.features.userdirectory.UserDirectoryViewModel
import kotlinx.android.synthetic.main.activity.*
import org.matrix.android.sdk.api.extensions.tryThis
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
import timber.log.Timber
import java.net.HttpURLConnection
import javax.inject.Inject
@ -113,7 +115,13 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
if (allGranted(grantResults)) {
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
try {
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
} catch (throwable: Throwable) {
Timber.w(throwable)
// Bug on API23
postResumeScheduledAction = Runnable { tryThis { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } }
}
}
}
}

View File

@ -45,9 +45,11 @@ import im.vector.app.features.userdirectory.UserDirectoryFragment
import im.vector.app.features.userdirectory.UserDirectorySharedAction
import im.vector.app.features.userdirectory.UserDirectorySharedActionViewModel
import im.vector.app.features.userdirectory.UserDirectoryViewModel
import org.matrix.android.sdk.api.failure.Failure
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.activity.*
import org.matrix.android.sdk.api.extensions.tryThis
import org.matrix.android.sdk.api.failure.Failure
import timber.log.Timber
import java.net.HttpURLConnection
import javax.inject.Inject
@ -114,7 +116,13 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
if (allGranted(grantResults)) {
if (requestCode == PERMISSION_REQUEST_CODE_READ_CONTACTS) {
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
try {
addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java)
} catch (throwable: Throwable) {
Timber.w(throwable)
// Bug on API23
postResumeScheduledAction = Runnable { tryThis { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } }
}
}
}
}