diff --git a/changelog.d/3655.bugfix b/changelog.d/3655.bugfix new file mode 100644 index 0000000000..c7e805ab84 --- /dev/null +++ b/changelog.d/3655.bugfix @@ -0,0 +1 @@ +Fix unread messages marker being hidden in collapsed membership item diff --git a/changelog.d/3661.bugfix b/changelog.d/3661.bugfix new file mode 100644 index 0000000000..9ca6b7d188 --- /dev/null +++ b/changelog.d/3661.bugfix @@ -0,0 +1 @@ +Ensure reaction emoji picker tabs look fine on small displays diff --git a/changelog.d/3667.feature b/changelog.d/3667.feature new file mode 100644 index 0000000000..439a890dd0 --- /dev/null +++ b/changelog.d/3667.feature @@ -0,0 +1 @@ +Better management of permission requests \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt index f8a8354e48..1d40e5defd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt @@ -97,7 +97,7 @@ internal class DefaultInitializeCrossSigningTask @Inject constructor( Timber.v("## CrossSigning - sskPublicKey:$sskPublicKey") - // Sign userSigningKey with master + // Sign selfSigningKey with master val signedSSK = CryptoCrossSigningKey.Builder(userId, KeyUsage.SELF_SIGNING) .key(sskPublicKey) .build() diff --git a/vector/src/debug/AndroidManifest.xml b/vector/src/debug/AndroidManifest.xml index b97384099f..8ffcec6bc1 100644 --- a/vector/src/debug/AndroidManifest.xml +++ b/vector/src/debug/AndroidManifest.xml @@ -4,6 +4,7 @@ + diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt index 539091c7ce..4b5228d199 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt @@ -30,9 +30,8 @@ import im.vector.app.core.di.ScreenComponent import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.utils.PERMISSIONS_FOR_TAKING_PHOTO -import im.vector.app.core.utils.PERMISSION_REQUEST_CODE_LAUNCH_CAMERA -import im.vector.app.core.utils.allGranted import im.vector.app.core.utils.checkPermissions +import im.vector.app.core.utils.registerForPermissionsResult import im.vector.app.core.utils.toast import im.vector.app.databinding.ActivityDebugMenuBinding import im.vector.app.features.debug.sas.DebugSasEmojiActivity @@ -48,7 +47,6 @@ import im.vector.lib.ui.styles.debug.DebugVectorButtonStylesLightActivity import im.vector.lib.ui.styles.debug.DebugVectorTextViewDarkActivity import im.vector.lib.ui.styles.debug.DebugVectorTextViewLightActivity import org.matrix.android.sdk.internal.crypto.verification.qrcode.toQrCodeData - import timber.log.Timber import javax.inject.Inject @@ -115,6 +113,9 @@ class DebugMenuActivity : VectorBaseActivity() { } views.debugTestCrash.setOnClickListener { testCrash() } views.debugScanQrCode.setOnClickListener { scanQRCode() } + views.debugPermission.setOnClickListener { + startActivity(Intent(this, DebugPermissionActivity::class.java)) + } } private fun renderQrCode(text: String) { @@ -217,15 +218,13 @@ class DebugMenuActivity : VectorBaseActivity() { } private fun scanQRCode() { - if (checkPermissions(PERMISSIONS_FOR_TAKING_PHOTO, this, PERMISSION_REQUEST_CODE_LAUNCH_CAMERA)) { + if (checkPermissions(PERMISSIONS_FOR_TAKING_PHOTO, this, permissionCameraLauncher)) { doScanQRCode() } } - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults) - - if (requestCode == PERMISSION_REQUEST_CODE_LAUNCH_CAMERA && allGranted(grantResults)) { + private val permissionCameraLauncher = registerForPermissionsResult { allGranted, _ -> + if (allGranted) { doScanQRCode() } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt new file mode 100644 index 0000000000..048c64bc3a --- /dev/null +++ b/vector/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt @@ -0,0 +1,135 @@ +/* + * Copyright 2021 New Vector Ltd + * + * Licensed 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 im.vector.app.features.debug + +import android.Manifest +import android.content.pm.PackageManager +import android.os.Build +import android.widget.Toast +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import im.vector.app.R +import im.vector.app.core.platform.VectorBaseActivity +import im.vector.app.core.utils.checkPermissions +import im.vector.app.core.utils.onPermissionDeniedDialog +import im.vector.app.core.utils.onPermissionDeniedSnackbar +import im.vector.app.core.utils.registerForPermissionsResult +import im.vector.app.databinding.ActivityDebugPermissionBinding +import timber.log.Timber + +class DebugPermissionActivity : VectorBaseActivity() { + + override fun getBinding() = ActivityDebugPermissionBinding.inflate(layoutInflater) + + override fun getCoordinatorLayout() = views.coordinatorLayout + + // For debug + private val allPermissions = listOf( + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.READ_CONTACTS) + + private var lastPermissions = emptyList() + + override fun initUiAndData() { + views.status.setOnClickListener { refresh() } + + views.camera.setOnClickListener { + lastPermissions = listOf(Manifest.permission.CAMERA) + checkPerm() + } + views.audio.setOnClickListener { + lastPermissions = listOf(Manifest.permission.RECORD_AUDIO) + checkPerm() + } + views.cameraAudio.setOnClickListener { + lastPermissions = listOf(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) + checkPerm() + } + views.write.setOnClickListener { + lastPermissions = listOf(Manifest.permission.WRITE_EXTERNAL_STORAGE) + checkPerm() + } + views.read.setOnClickListener { + lastPermissions = listOf(Manifest.permission.READ_EXTERNAL_STORAGE) + checkPerm() + } + views.contact.setOnClickListener { + lastPermissions = listOf(Manifest.permission.READ_CONTACTS) + checkPerm() + } + } + + private fun checkPerm() { + if (checkPermissions(lastPermissions, this, launcher, R.string.debug_rationale)) { + Toast.makeText(this, "Already granted, sync call", Toast.LENGTH_SHORT).show() + } + } + + private var dialogOrSnackbar = false + + private val launcher = registerForPermissionsResult { allGranted, deniedPermanently -> + if (allGranted) { + Toast.makeText(this, "All granted", Toast.LENGTH_SHORT).show() + } else { + if (deniedPermanently) { + dialogOrSnackbar = !dialogOrSnackbar + if (dialogOrSnackbar) { + onPermissionDeniedDialog(R.string.denied_permission_generic) + } else { + onPermissionDeniedSnackbar(R.string.denied_permission_generic) + } + } else { + Toast.makeText(this, "Denied", Toast.LENGTH_SHORT).show() + } + } + } + + override fun onResume() { + super.onResume() + refresh() + } + + private fun refresh() { + views.status.text = getStatus() + } + + private fun getStatus(): String { + return buildString { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + Timber.v("## debugPermission() : log the permissions status used by the app") + allPermissions.forEach { permission -> + append("[$permission] : ") + if (ContextCompat.checkSelfPermission(this@DebugPermissionActivity, permission) == PackageManager.PERMISSION_GRANTED) { + append("PERMISSION_GRANTED") + } else { + append("PERMISSION_DENIED") + } + append(" show rational: ") + append(ActivityCompat.shouldShowRequestPermissionRationale(this@DebugPermissionActivity, permission)) + append("\n") + } + } else { + append("Before M!") + } + append("\n") + append("(Click to refresh)") + } + } +} diff --git a/vector/src/debug/res/layout/activity_debug_menu.xml b/vector/src/debug/res/layout/activity_debug_menu.xml index a83f61266a..fadffecf83 100644 --- a/vector/src/debug/res/layout/activity_debug_menu.xml +++ b/vector/src/debug/res/layout/activity_debug_menu.xml @@ -152,6 +152,12 @@ android:layout_height="200dp" tools:src="@drawable/ic_qr_code_add" /> +