userAgent, userId and deviceId in rageshake

This commit is contained in:
Benoit Marty 2019-03-28 17:42:39 +01:00
parent be2dad9b17
commit 317503aa2b
10 changed files with 32 additions and 37 deletions

View File

@ -65,7 +65,7 @@ class AppModule(private val context: Context) {
} }


factory { factory {
Matrix.getInstance().currentSession Matrix.getInstance().currentSession!!
} }





View File

@ -263,7 +263,7 @@ abstract class RiotActivity : BaseMvRxActivity() {
open fun getMenuRes() = -1 open fun getMenuRes() = -1


@AttrRes @AttrRes
open fun getMenuTint() = 0 // TODO R.attr.vctr_icon_tint_on_dark_action_bar_color open fun getMenuTint() = R.attr.vctr_icon_tint_on_dark_action_bar_color


/** /**
* Return a object containing other themes for this activity * Return a object containing other themes for this activity

View File

@ -90,7 +90,7 @@ object AvatarRenderer {
// PRIVATE API ********************************************************************************* // PRIVATE API *********************************************************************************


private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest<Drawable> { private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest<Drawable> {
val resolvedUrl = Matrix.getInstance().currentSession val resolvedUrl = Matrix.getInstance().currentSession!!
.contentUrlResolver() .contentUrlResolver()
.resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE) .resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE)



View File

@ -41,7 +41,7 @@ class HomeActivityViewModel(state: EmptyState,


@JvmStatic @JvmStatic
override fun create(viewModelContext: ViewModelContext, state: EmptyState): HomeActivityViewModel? { override fun create(viewModelContext: ViewModelContext, state: EmptyState): HomeActivityViewModel? {
val session = Matrix.getInstance().currentSession val session = Matrix.getInstance().currentSession!!
val roomSelectionRepository = viewModelContext.activity.get<RoomSelectionRepository>() val roomSelectionRepository = viewModelContext.activity.get<RoomSelectionRepository>()
return HomeActivityViewModel(state, session, roomSelectionRepository) return HomeActivityViewModel(state, session, roomSelectionRepository)
} }

View File

@ -63,8 +63,7 @@ class LoginActivity : RiotActivity() {
progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> { authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
override fun onSuccess(data: Session) { override fun onSuccess(data: Session) {
Matrix.getInstance().currentSession = data Matrix.getInstance().currentSession = data.apply { open() }
Matrix.getInstance().currentSession.open()
goToHome() goToHome()
} }



View File

@ -49,7 +49,7 @@ object MediaContentRenderer {
val (width, height) = processSize(data, mode) val (width, height) = processSize(data, mode)
imageView.layoutParams.height = height imageView.layoutParams.height = height
imageView.layoutParams.width = width imageView.layoutParams.width = width
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver() val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
val resolvedUrl = when (mode) { val resolvedUrl = when (mode) {
Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url) Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url)
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE) Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
@ -64,7 +64,7 @@ object MediaContentRenderer {


fun render(data: Data, imageView: BigImageView) { fun render(data: Data, imageView: BigImageView) {
val (width, height) = processSize(data, Mode.THUMBNAIL) val (width, height) = processSize(data, Mode.THUMBNAIL)
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver() val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
val fullSize = contentUrlResolver.resolveFullSize(data.url) val fullSize = contentUrlResolver.resolveFullSize(data.url)
val thumbnail = contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE) val thumbnail = contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
imageView.showImage( imageView.showImage(

View File

@ -25,9 +25,9 @@ import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.os.AsyncTask import android.os.AsyncTask
import android.os.Build import android.os.Build
import android.os.Environment
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import im.vector.matrix.android.api.Matrix
import im.vector.riotredesign.BuildConfig import im.vector.riotredesign.BuildConfig
import im.vector.riotredesign.R import im.vector.riotredesign.R
import im.vector.riotredesign.core.extensions.toOnOff import im.vector.riotredesign.core.extensions.toOnOff
@ -81,11 +81,8 @@ object BugReporter {
"-v", // formatting "-v", // formatting
"threadtime", // include timestamps "threadtime", // include timestamps
"AndroidRuntime:E " + ///< Pick all AndroidRuntime errors (such as uncaught exceptions)"communicatorjni:V " + ///< All communicatorjni logging "AndroidRuntime:E " + ///< Pick all AndroidRuntime errors (such as uncaught exceptions)"communicatorjni:V " + ///< All communicatorjni logging

"libcommunicator:V " + ///< All libcommunicator logging "libcommunicator:V " + ///< All libcommunicator logging

"DEBUG:V " + ///< All DEBUG logging - which includes native land crashes (seg faults, etc) "DEBUG:V " + ///< All DEBUG logging - which includes native land crashes (seg faults, etc)

"*:S" ///< Everything else silent, so don't pick it.. "*:S" ///< Everything else silent, so don't pick it..
) )


@ -155,7 +152,7 @@ object BugReporter {
val gzippedFiles = ArrayList<File>() val gzippedFiles = ArrayList<File>()


if (withDevicesLogs) { if (withDevicesLogs) {
val files = VectorFileLogger.addLogFiles(ArrayList<File>()) val files = VectorFileLogger.getLogFiles()


for (f in files) { for (f in files) {
if (!mIsCancelled) { if (!mIsCancelled) {
@ -166,8 +163,6 @@ object BugReporter {
} }
} }
} }

// TODO Delete the sent files?
} }


if (!mIsCancelled && (withCrashLogs || withDevicesLogs)) { if (!mIsCancelled && (withCrashLogs || withDevicesLogs)) {
@ -195,29 +190,24 @@ object BugReporter {
} }
} }


// TODO MXSession session = Matrix.getInstance(context).getDefaultSession(); var deviceId = "undefined"
var userId = "undefined"
var matrixSdkVersion = "undefined"
var olmVersion = "undefined"


val deviceId = "undefined" Matrix.getInstance().currentSession?.let { session ->
val userId = "undefined" userId = session.sessionParams.credentials.userId
val matrixSdkVersion = "undefined" deviceId = session.sessionParams.credentials.deviceId ?: "undefined"
val olmVersion = "undefined" // TODO matrixSdkVersion = session.getVersion(true);

// TODO olmVersion = session.getCryptoVersion(context, true);
/*
TODO
if (null != session) {
userId = session.getMyUserId();
deviceId = session.getCredentials().deviceId;
matrixSdkVersion = session.getVersion(true);
olmVersion = session.getCryptoVersion(context, true);
} }
*/


if (!mIsCancelled) { if (!mIsCancelled) {
// build the multi part request // build the multi part request
val builder = BugReporterMultipartBody.Builder() val builder = BugReporterMultipartBody.Builder()
.addFormDataPart("text", "[RiotX] $bugDescription") .addFormDataPart("text", "[RiotX] $bugDescription")
.addFormDataPart("app", "riot-android") .addFormDataPart("app", "riot-android")
// TODO .addFormDataPart("user_agent", RestClient.getUserAgent()) .addFormDataPart("user_agent", Matrix.getInstance().getUserAgent())
.addFormDataPart("user_id", userId) .addFormDataPart("user_id", userId)
.addFormDataPart("device_id", deviceId) .addFormDataPart("device_id", deviceId)
// TODO .addFormDataPart("version", Matrix.getInstance(context).getVersion(true, false)) // TODO .addFormDataPart("version", Matrix.getInstance(context).getVersion(true, false))

View File

@ -27,6 +27,7 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
import java.util.logging.* import java.util.logging.*
import java.util.logging.Formatter import java.util.logging.Formatter
import kotlin.collections.ArrayList


object VectorFileLogger : Timber.DebugTree() { object VectorFileLogger : Timber.DebugTree() {


@ -92,7 +93,9 @@ object VectorFileLogger : Timber.DebugTree() {
* @param files The list of files to add to. * @param files The list of files to add to.
* @return The same list with more files added. * @return The same list with more files added.
*/ */
fun addLogFiles(files: MutableList<File>): List<File> { fun getLogFiles(): List<File> {
val files = ArrayList<File>()

try { try {
// reported by GA // reported by GA
if (null != sFileHandler) { if (null != sFileHandler) {

View File

@ -81,7 +81,7 @@ object FontScale {
putString(APPLICATION_FONT_SCALE_KEY, scalePreferenceValue) putString(APPLICATION_FONT_SCALE_KEY, scalePreferenceValue)
} }
} else { } else {
scalePreferenceValue = preferences.getString(APPLICATION_FONT_SCALE_KEY, FONT_SCALE_NORMAL) scalePreferenceValue = preferences.getString(APPLICATION_FONT_SCALE_KEY, FONT_SCALE_NORMAL)!!
} }


return scalePreferenceValue return scalePreferenceValue

View File

@ -39,9 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean
class Matrix private constructor(context: Context) : MatrixKoinComponent { class Matrix private constructor(context: Context) : MatrixKoinComponent {


private val authenticator by inject<Authenticator>() private val authenticator by inject<Authenticator>()
private val userAgent by inject<UserAgentHolder>() private val userAgentHolder by inject<UserAgentHolder>()
private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>() private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>()
lateinit var currentSession: Session var currentSession: Session? = null


init { init {
Monarchy.init(context) Monarchy.init(context)
@ -52,8 +52,9 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver) ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
val lastActiveSession = authenticator.getLastActiveSession() val lastActiveSession = authenticator.getLastActiveSession()
if (lastActiveSession != null) { if (lastActiveSession != null) {
currentSession = lastActiveSession currentSession = lastActiveSession.apply {
currentSession.open() open()
}
} }
} }


@ -65,9 +66,11 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
* Set application flavor, to alter user agent. * Set application flavor, to alter user agent.
*/ */
fun setApplicationFlavor(flavor: String) { fun setApplicationFlavor(flavor: String) {
userAgent.setApplicationFlavor(flavor) userAgentHolder.setApplicationFlavor(flavor)
} }


fun getUserAgent() = userAgentHolder.userAgent

companion object { companion object {
private lateinit var instance: Matrix private lateinit var instance: Matrix
private val isInit = AtomicBoolean(false) private val isInit = AtomicBoolean(false)