userAgent, userId and deviceId in rageshake
This commit is contained in:
parent
be2dad9b17
commit
317503aa2b
|
@ -65,7 +65,7 @@ class AppModule(private val context: Context) {
|
|||
}
|
||||
|
||||
factory {
|
||||
Matrix.getInstance().currentSession
|
||||
Matrix.getInstance().currentSession!!
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ abstract class RiotActivity : BaseMvRxActivity() {
|
|||
open fun getMenuRes() = -1
|
||||
|
||||
@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
|
||||
|
|
|
@ -90,7 +90,7 @@ object AvatarRenderer {
|
|||
// PRIVATE API *********************************************************************************
|
||||
|
||||
private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest<Drawable> {
|
||||
val resolvedUrl = Matrix.getInstance().currentSession
|
||||
val resolvedUrl = Matrix.getInstance().currentSession!!
|
||||
.contentUrlResolver()
|
||||
.resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class HomeActivityViewModel(state: EmptyState,
|
|||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: EmptyState): HomeActivityViewModel? {
|
||||
val session = Matrix.getInstance().currentSession
|
||||
val session = Matrix.getInstance().currentSession!!
|
||||
val roomSelectionRepository = viewModelContext.activity.get<RoomSelectionRepository>()
|
||||
return HomeActivityViewModel(state, session, roomSelectionRepository)
|
||||
}
|
||||
|
|
|
@ -63,8 +63,7 @@ class LoginActivity : RiotActivity() {
|
|||
progressBar.visibility = View.VISIBLE
|
||||
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
|
||||
override fun onSuccess(data: Session) {
|
||||
Matrix.getInstance().currentSession = data
|
||||
Matrix.getInstance().currentSession.open()
|
||||
Matrix.getInstance().currentSession = data.apply { open() }
|
||||
goToHome()
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ object MediaContentRenderer {
|
|||
val (width, height) = processSize(data, mode)
|
||||
imageView.layoutParams.height = height
|
||||
imageView.layoutParams.width = width
|
||||
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver()
|
||||
val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
|
||||
val resolvedUrl = when (mode) {
|
||||
Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url)
|
||||
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
|
@ -64,7 +64,7 @@ object MediaContentRenderer {
|
|||
|
||||
fun render(data: Data, imageView: BigImageView) {
|
||||
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 thumbnail = contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
imageView.showImage(
|
||||
|
|
|
@ -25,9 +25,9 @@ import android.content.Intent
|
|||
import android.graphics.Bitmap
|
||||
import android.os.AsyncTask
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.riotredesign.BuildConfig
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.extensions.toOnOff
|
||||
|
@ -81,11 +81,8 @@ object BugReporter {
|
|||
"-v", // formatting
|
||||
"threadtime", // include timestamps
|
||||
"AndroidRuntime:E " + ///< Pick all AndroidRuntime errors (such as uncaught exceptions)"communicatorjni:V " + ///< All communicatorjni logging
|
||||
|
||||
"libcommunicator:V " + ///< All libcommunicator logging
|
||||
|
||||
"DEBUG:V " + ///< All DEBUG logging - which includes native land crashes (seg faults, etc)
|
||||
|
||||
"*:S" ///< Everything else silent, so don't pick it..
|
||||
)
|
||||
|
||||
|
@ -155,7 +152,7 @@ object BugReporter {
|
|||
val gzippedFiles = ArrayList<File>()
|
||||
|
||||
if (withDevicesLogs) {
|
||||
val files = VectorFileLogger.addLogFiles(ArrayList<File>())
|
||||
val files = VectorFileLogger.getLogFiles()
|
||||
|
||||
for (f in files) {
|
||||
if (!mIsCancelled) {
|
||||
|
@ -166,8 +163,6 @@ object BugReporter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Delete the sent files?
|
||||
}
|
||||
|
||||
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"
|
||||
val userId = "undefined"
|
||||
val matrixSdkVersion = "undefined"
|
||||
val olmVersion = "undefined"
|
||||
|
||||
/*
|
||||
TODO
|
||||
if (null != session) {
|
||||
userId = session.getMyUserId();
|
||||
deviceId = session.getCredentials().deviceId;
|
||||
matrixSdkVersion = session.getVersion(true);
|
||||
olmVersion = session.getCryptoVersion(context, true);
|
||||
Matrix.getInstance().currentSession?.let { session ->
|
||||
userId = session.sessionParams.credentials.userId
|
||||
deviceId = session.sessionParams.credentials.deviceId ?: "undefined"
|
||||
// TODO matrixSdkVersion = session.getVersion(true);
|
||||
// TODO olmVersion = session.getCryptoVersion(context, true);
|
||||
}
|
||||
*/
|
||||
|
||||
if (!mIsCancelled) {
|
||||
// build the multi part request
|
||||
val builder = BugReporterMultipartBody.Builder()
|
||||
.addFormDataPart("text", "[RiotX] $bugDescription")
|
||||
.addFormDataPart("app", "riot-android")
|
||||
// TODO .addFormDataPart("user_agent", RestClient.getUserAgent())
|
||||
.addFormDataPart("user_agent", Matrix.getInstance().getUserAgent())
|
||||
.addFormDataPart("user_id", userId)
|
||||
.addFormDataPart("device_id", deviceId)
|
||||
// TODO .addFormDataPart("version", Matrix.getInstance(context).getVersion(true, false))
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.text.SimpleDateFormat
|
|||
import java.util.*
|
||||
import java.util.logging.*
|
||||
import java.util.logging.Formatter
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
object VectorFileLogger : Timber.DebugTree() {
|
||||
|
||||
|
@ -92,7 +93,9 @@ object VectorFileLogger : Timber.DebugTree() {
|
|||
* @param files The list of files to add to.
|
||||
* @return The same list with more files added.
|
||||
*/
|
||||
fun addLogFiles(files: MutableList<File>): List<File> {
|
||||
fun getLogFiles(): List<File> {
|
||||
val files = ArrayList<File>()
|
||||
|
||||
try {
|
||||
// reported by GA
|
||||
if (null != sFileHandler) {
|
||||
|
|
|
@ -81,7 +81,7 @@ object FontScale {
|
|||
putString(APPLICATION_FONT_SCALE_KEY, scalePreferenceValue)
|
||||
}
|
||||
} else {
|
||||
scalePreferenceValue = preferences.getString(APPLICATION_FONT_SCALE_KEY, FONT_SCALE_NORMAL)
|
||||
scalePreferenceValue = preferences.getString(APPLICATION_FONT_SCALE_KEY, FONT_SCALE_NORMAL)!!
|
||||
}
|
||||
|
||||
return scalePreferenceValue
|
||||
|
|
|
@ -39,9 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
class Matrix private constructor(context: Context) : MatrixKoinComponent {
|
||||
|
||||
private val authenticator by inject<Authenticator>()
|
||||
private val userAgent by inject<UserAgentHolder>()
|
||||
private val userAgentHolder by inject<UserAgentHolder>()
|
||||
private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>()
|
||||
lateinit var currentSession: Session
|
||||
var currentSession: Session? = null
|
||||
|
||||
init {
|
||||
Monarchy.init(context)
|
||||
|
@ -52,8 +52,9 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
|
|||
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
|
||||
val lastActiveSession = authenticator.getLastActiveSession()
|
||||
if (lastActiveSession != null) {
|
||||
currentSession = lastActiveSession
|
||||
currentSession.open()
|
||||
currentSession = lastActiveSession.apply {
|
||||
open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,9 +66,11 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
|
|||
* Set application flavor, to alter user agent.
|
||||
*/
|
||||
fun setApplicationFlavor(flavor: String) {
|
||||
userAgent.setApplicationFlavor(flavor)
|
||||
userAgentHolder.setApplicationFlavor(flavor)
|
||||
}
|
||||
|
||||
fun getUserAgent() = userAgentHolder.userAgent
|
||||
|
||||
companion object {
|
||||
private lateinit var instance: Matrix
|
||||
private val isInit = AtomicBoolean(false)
|
||||
|
|
Loading…
Reference in New Issue