Merge pull request #2016 from vector-im/feature/sonar_fixes
Sonar fixes
This commit is contained in:
commit
a0af769d7c
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,6 @@
|
|||||||
### Pull Request Checklist
|
### Pull Request Checklist
|
||||||
|
|
||||||
<!-- Please read [CONTRIBUTING.md](https://github.com/vector-im/riotX-android/blob/develop/CONTRIBUTING.md) before submitting your pull request -->
|
<!-- Please read [CONTRIBUTING.md](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md) before submitting your pull request -->
|
||||||
|
|
||||||
- [ ] Changes has been tested on an Android device or Android emulator with API 21
|
- [ ] Changes has been tested on an Android device or Android emulator with API 21
|
||||||
- [ ] UI change has been tested on both light and dark themes
|
- [ ] UI change has been tested on both light and dark themes
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
A full developer contributors list can be found [here](https://github.com/vector-im/riotX-android/graphs/contributors).
|
A full developer contributors list can be found [here](https://github.com/vector-im/element-android/graphs/contributors).
|
||||||
|
|
||||||
# Core team:
|
# Core team:
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[](https://buildkite.com/matrix-dot-org/riotx-android/builds?branch=develop)
|
[](https://buildkite.com/matrix-dot-org/riotx-android/builds?branch=develop)
|
||||||
[](https://translate.riot.im/engage/element-android/?utm_source=widget)
|
[](https://translate.riot.im/engage/element-android/?utm_source=widget)
|
||||||
[](https://matrix.to/#/#element-android:matrix.org)
|
[](https://matrix.to/#/#element-android:matrix.org)
|
||||||
[](https://sonarcloud.io/dashboard?id=vector.android.riotx)
|
[](https://sonarcloud.io/dashboard?id=im.vector.app.android)
|
||||||
[](https://sonarcloud.io/dashboard?id=vector.android.riotx)
|
[](https://sonarcloud.io/dashboard?id=im.vector.app.android)
|
||||||
[](https://sonarcloud.io/dashboard?id=vector.android.riotx)
|
[](https://sonarcloud.io/dashboard?id=im.vector.app.android)
|
||||||
|
|
||||||
# Element Android
|
# Element Android
|
||||||
|
|
||||||
@ -27,6 +27,6 @@ The team will work to add them on a regular basis.
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Please refer to [CONTRIBUTING.md](https://github.com/vector-im/riotX-android/blob/develop/CONTRIBUTING.md) if you want to contribute on Matrix Android projects!
|
Please refer to [CONTRIBUTING.md](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md) if you want to contribute on Matrix Android projects!
|
||||||
|
|
||||||
Come chat with the community in the dedicated Matrix [room](https://matrix.to/#/#element-android:matrix.org).
|
Come chat with the community in the dedicated Matrix [room](https://matrix.to/#/#element-android:matrix.org).
|
||||||
|
19
build.gradle
19
build.gradle
@ -81,15 +81,15 @@ apply plugin: 'org.sonarqube'
|
|||||||
|
|
||||||
sonarqube {
|
sonarqube {
|
||||||
properties {
|
properties {
|
||||||
property "sonar.projectName", "RiotX-Android"
|
property "sonar.projectName", "Element-Android"
|
||||||
property "sonar.projectKey", "vector.android.riotx"
|
property "sonar.projectKey", "im.vector.app.android"
|
||||||
property "sonar.host.url", "https://sonarcloud.io"
|
property "sonar.host.url", "https://sonarcloud.io"
|
||||||
property "sonar.projectVersion", project(":vector").android.defaultConfig.versionName
|
property "sonar.projectVersion", project(":vector").android.defaultConfig.versionName
|
||||||
property "sonar.sourceEncoding", "UTF-8"
|
property "sonar.sourceEncoding", "UTF-8"
|
||||||
property "sonar.links.homepage", "https://github.com/vector-im/riotX-android/"
|
property "sonar.links.homepage", "https://github.com/vector-im/element-android/"
|
||||||
property "sonar.links.ci", "https://buildkite.com/matrix-dot-org/riotx-android"
|
property "sonar.links.ci", "https://buildkite.com/matrix-dot-org/riotx-android"
|
||||||
property "sonar.links.scm", "https://github.com/vector-im/riotX-android/"
|
property "sonar.links.scm", "https://github.com/vector-im/element-android/"
|
||||||
property "sonar.links.issue", "https://github.com/vector-im/riotX-android/issues"
|
property "sonar.links.issue", "https://github.com/vector-im/element-android/issues"
|
||||||
property "sonar.organization", "new_vector_ltd_organization"
|
property "sonar.organization", "new_vector_ltd_organization"
|
||||||
property "sonar.login", project.hasProperty("SONAR_LOGIN") ? SONAR_LOGIN : "invalid"
|
property "sonar.login", project.hasProperty("SONAR_LOGIN") ? SONAR_LOGIN : "invalid"
|
||||||
}
|
}
|
||||||
@ -100,11 +100,18 @@ project(":vector") {
|
|||||||
properties {
|
properties {
|
||||||
property "sonar.sources", project(":vector").android.sourceSets.main.java.srcDirs
|
property "sonar.sources", project(":vector").android.sourceSets.main.java.srcDirs
|
||||||
// exclude source code from analyses separated by a colon (:)
|
// exclude source code from analyses separated by a colon (:)
|
||||||
// property "sonar.exclusions", "**/*.*"
|
// Exclude Java source
|
||||||
|
property "sonar.exclusions", "**/BugReporterMultipartBody.java"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project(":diff-match-patch") {
|
||||||
|
sonarqube {
|
||||||
|
skipProject = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//project(":matrix-sdk-android") {
|
//project(":matrix-sdk-android") {
|
||||||
// sonarqube {
|
// sonarqube {
|
||||||
// properties {
|
// properties {
|
||||||
|
@ -122,6 +122,9 @@ android {
|
|||||||
// Other branches (master, features, etc.) will have version code based on application version.
|
// Other branches (master, features, etc.) will have version code based on application version.
|
||||||
versionCode project.getVersionCode()
|
versionCode project.getVersionCode()
|
||||||
|
|
||||||
|
// Required for sonar analysis
|
||||||
|
versionName "${versionMajor}.${versionMinor}.${versionPatch}-sonar"
|
||||||
|
|
||||||
buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\""
|
buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\""
|
||||||
resValue "string", "git_revision", "\"${gitRevision()}\""
|
resValue "string", "git_revision", "\"${gitRevision()}\""
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class DebugMenuActivity : VectorBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun renderQrCode(text: String) {
|
private fun renderQrCode(text: String) {
|
||||||
debug_qr_code.setData(text, true)
|
debug_qr_code.setData(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.debug_test_text_view_link)
|
@OnClick(R.id.debug_test_text_view_link)
|
||||||
|
@ -18,28 +18,23 @@ package im.vector.app.core.ui.views
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.AnimationDrawable
|
|
||||||
import android.graphics.drawable.BitmapDrawable
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
import im.vector.app.core.qrcode.toBitMatrix
|
import im.vector.app.core.qrcode.toBitMatrix
|
||||||
import im.vector.app.core.qrcode.toBitmap
|
import im.vector.app.core.qrcode.toBitmap
|
||||||
import kotlin.random.Random
|
|
||||||
|
|
||||||
class QrCodeImageView @JvmOverloads constructor(
|
class QrCodeImageView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
private var data: String? = null
|
private var data: String? = null
|
||||||
private var animate = false
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setBackgroundColor(Color.WHITE)
|
setBackgroundColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setData(data: String, animate: Boolean) {
|
fun setData(data: String) {
|
||||||
this.data = data
|
this.data = data
|
||||||
this.animate = animate
|
|
||||||
|
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
@ -53,47 +48,8 @@ class QrCodeImageView @JvmOverloads constructor(
|
|||||||
data
|
data
|
||||||
?.takeIf { height > 0 }
|
?.takeIf { height > 0 }
|
||||||
?.let {
|
?.let {
|
||||||
if (animate) {
|
val bitmap = it.toBitMatrix(height).toBitmap()
|
||||||
// NOT SUPPORTED YET val anim = createAnimation(it)
|
post { setImageBitmap(bitmap) }
|
||||||
// NOT SUPPORTED YET setImageDrawable(anim)
|
|
||||||
// NOT SUPPORTED YET anim.start()
|
|
||||||
// NOT SUPPORTED YET setImageDrawable(BitmapDrawable(resources, it.toBitMatrix(height).toBitmap()))
|
|
||||||
val bitmap = it.toBitMatrix(height).toBitmap()
|
|
||||||
post { setImageBitmap(bitmap) }
|
|
||||||
} else {
|
|
||||||
val bitmap = it.toBitMatrix(height).toBitmap()
|
|
||||||
post { setImageBitmap(bitmap) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createAnimation(data: String): AnimationDrawable {
|
|
||||||
val finalQr = data.toBitMatrix(height)
|
|
||||||
|
|
||||||
val list = mutableListOf(finalQr)
|
|
||||||
|
|
||||||
val random = Random(System.currentTimeMillis())
|
|
||||||
val repeatTime = 8
|
|
||||||
repeat(repeatTime) { index ->
|
|
||||||
val alteredQr = finalQr.clone()
|
|
||||||
for (x in 0 until alteredQr.width) {
|
|
||||||
for (y in 0 until alteredQr.height) {
|
|
||||||
if (random.nextInt(repeatTime - index) == 0) {
|
|
||||||
// Pb is that it does not toggle a whole black square, but only a pixel
|
|
||||||
alteredQr.unset(x, y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.add(alteredQr)
|
|
||||||
}
|
|
||||||
|
|
||||||
val animDrawable = AnimationDrawable()
|
|
||||||
|
|
||||||
list.asReversed()
|
|
||||||
.forEach {
|
|
||||||
animDrawable.addFrame(BitmapDrawable(resources, it.toBitmap()), 150)
|
|
||||||
}
|
|
||||||
|
|
||||||
return animDrawable
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ class VerificationChooseMethodController @Inject constructor(
|
|||||||
bottomSheetVerificationQrCodeItem {
|
bottomSheetVerificationQrCodeItem {
|
||||||
id("qr")
|
id("qr")
|
||||||
data(state.qrCodeText)
|
data(state.qrCodeText)
|
||||||
animate(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dividerItem {
|
dividerItem {
|
||||||
|
@ -32,12 +32,9 @@ abstract class BottomSheetVerificationQrCodeItem : VectorEpoxyModel<BottomSheetV
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
lateinit var data: String
|
lateinit var data: String
|
||||||
|
|
||||||
@EpoxyAttribute
|
|
||||||
var animate = false
|
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
holder.qsrCodeImage.setData(data, animate)
|
holder.qsrCodeImage.setData(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Holder : VectorEpoxyHolder() {
|
class Holder : VectorEpoxyHolder() {
|
||||||
|
@ -28,6 +28,7 @@ import kotlinx.android.parcel.Parcelize
|
|||||||
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
|
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryData
|
import org.matrix.android.sdk.api.session.room.model.thirdparty.RoomDirectoryData
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class RoomPreviewData(
|
data class RoomPreviewData(
|
||||||
@ -83,6 +84,7 @@ class RoomPreviewActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||||||
if (args?.worldReadable == true) {
|
if (args?.worldReadable == true) {
|
||||||
// TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview
|
// TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview
|
||||||
// TODO the same way if it was not world readable
|
// TODO the same way if it was not world readable
|
||||||
|
Timber.d("just display the room preview the same way if it was not world readable")
|
||||||
addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)
|
addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)
|
||||||
} else {
|
} else {
|
||||||
addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)
|
addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package im.vector.app.features.settings
|
package im.vector.app.features.settings
|
||||||
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.preference.VectorSwitchPreference
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsLabsFragment @Inject constructor(
|
class VectorSettingsLabsFragment @Inject constructor(
|
||||||
@ -28,103 +27,6 @@ class VectorSettingsLabsFragment @Inject constructor(
|
|||||||
override val preferenceXmlRes = R.xml.vector_settings_labs
|
override val preferenceXmlRes = R.xml.vector_settings_labs
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
// Lab
|
// Nothing to do
|
||||||
|
|
||||||
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_ALLOW_EXTENDED_LOGS)?.let {
|
|
||||||
it.isChecked = vectorPreferences.labAllowedExtendedLogging()
|
|
||||||
}
|
|
||||||
|
|
||||||
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let {
|
|
||||||
it.isChecked = vectorPreferences.labAddNotificationTab()
|
|
||||||
}
|
|
||||||
|
|
||||||
// val useCryptoPref = findPreference(VectorPreferences.SETTINGS_ROOM_SETTINGS_LABS_END_TO_END_PREFERENCE_KEY) as SwitchPreference
|
|
||||||
// val cryptoIsEnabledPref = findPreference(VectorPreferences.SETTINGS_ROOM_SETTINGS_LABS_END_TO_END_IS_ACTIVE_PREFERENCE_KEY)
|
|
||||||
|
|
||||||
if (session.cryptoService().isCryptoEnabled()) {
|
|
||||||
// mLabsCategory.removePreference(useCryptoPref)
|
|
||||||
//
|
|
||||||
// cryptoIsEnabledPref.isEnabled = false
|
|
||||||
} else {
|
|
||||||
// mLabsCategory.removePreference(cryptoIsEnabledPref)
|
|
||||||
//
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
//
|
|
||||||
// useCryptoPref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValueAsVoid ->
|
|
||||||
// if (TextUtils.isEmpty(mSession.sessionParams.deviceId)) {
|
|
||||||
// activity?.let { activity ->
|
|
||||||
// AlertDialog.Builder(activity)
|
|
||||||
// .setMessage(R.string.room_settings_labs_end_to_end_warnings)
|
|
||||||
// .setPositiveButton(R.string.logout) { _, _ ->
|
|
||||||
// notImplemented()
|
|
||||||
// // TODO CommonActivityUtils.logout(activity)
|
|
||||||
// }
|
|
||||||
// .setNegativeButton(R.string.cancel) { _, _ ->
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
// }
|
|
||||||
// .setOnCancelListener {
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
// }
|
|
||||||
// .show()
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// val newValue = newValueAsVoid as Boolean
|
|
||||||
//
|
|
||||||
// if (mSession.isCryptoEnabled() != newValue) {
|
|
||||||
// notImplemented()
|
|
||||||
// /* TODO
|
|
||||||
// displayLoadingView()
|
|
||||||
//
|
|
||||||
// session.enableCrypto(newValue, object : MatrixCallback<Unit> {
|
|
||||||
// private fun refresh() {
|
|
||||||
// activity?.runOnUiThread {
|
|
||||||
// hideLoadingView()
|
|
||||||
// useCryptoPref.isChecked = session.isCryptoEnabled
|
|
||||||
//
|
|
||||||
// if (session.isCryptoEnabled) {
|
|
||||||
// mLabsCategory.removePreference(useCryptoPref)
|
|
||||||
// mLabsCategory.addPreference(cryptoIsEnabledPref)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onSuccess(info: Void?) {
|
|
||||||
// useCryptoPref.isEnabled = false
|
|
||||||
// refresh()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onNetworkError(e: Exception) {
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onMatrixError(e: MatrixError) {
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onUnexpectedError(e: Exception) {
|
|
||||||
// useCryptoPref.isChecked = false
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// */
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// true
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// SaveMode Management
|
|
||||||
// findPreference(VectorPreferences.SETTINGS_DATA_SAVE_MODE_PREFERENCE_KEY)
|
|
||||||
// .onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
|
||||||
// notImplemented()
|
|
||||||
// /* TODO
|
|
||||||
// val sessions = Matrix.getMXSessions(activity)
|
|
||||||
// for (session in sessions) {
|
|
||||||
// session.setUseDataSaveMode(newValue as Boolean)
|
|
||||||
// }
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
// true
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,8 @@ class VectorSettingsDevicesFragment @Inject constructor(
|
|||||||
) : VectorBaseFragment(), DevicesController.Callback {
|
) : VectorBaseFragment(), DevicesController.Callback {
|
||||||
|
|
||||||
// used to avoid requesting to enter the password for each deletion
|
// used to avoid requesting to enter the password for each deletion
|
||||||
private var mAccountPassword: String = ""
|
// Note: Sonar does not like to use password for member name.
|
||||||
|
private var mAccountPass: String = ""
|
||||||
|
|
||||||
override fun getLayoutResId() = R.layout.fragment_generic_recycler
|
override fun getLayoutResId() = R.layout.fragment_generic_recycler
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ class VectorSettingsDevicesFragment @Inject constructor(
|
|||||||
super.showFailure(throwable)
|
super.showFailure(throwable)
|
||||||
|
|
||||||
// Password is maybe not good, for safety measure, reset it here
|
// Password is maybe not good, for safety measure, reset it here
|
||||||
mAccountPassword = ""
|
mAccountPass = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
@ -153,12 +154,12 @@ class VectorSettingsDevicesFragment @Inject constructor(
|
|||||||
* Show a dialog to ask for user password, or use a previously entered password.
|
* Show a dialog to ask for user password, or use a previously entered password.
|
||||||
*/
|
*/
|
||||||
private fun maybeShowDeleteDeviceWithPasswordDialog() {
|
private fun maybeShowDeleteDeviceWithPasswordDialog() {
|
||||||
if (mAccountPassword.isNotEmpty()) {
|
if (mAccountPass.isNotEmpty()) {
|
||||||
viewModel.handle(DevicesAction.Password(mAccountPassword))
|
viewModel.handle(DevicesAction.Password(mAccountPass))
|
||||||
} else {
|
} else {
|
||||||
PromptPasswordDialog().show(requireActivity()) { password ->
|
PromptPasswordDialog().show(requireActivity()) { password ->
|
||||||
mAccountPassword = password
|
mAccountPass = password
|
||||||
viewModel.handle(DevicesAction.Password(mAccountPassword))
|
viewModel.handle(DevicesAction.Password(mAccountPass))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user