diff --git a/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt b/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt index f67c9c11..9c14a508 100644 --- a/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt +++ b/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt @@ -65,7 +65,7 @@ class AppModule(private val context: Context) { } factory { - Matrix.getInstance().currentSession + Matrix.getInstance().currentSession!! } diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt index 2cfbe3b9..06b1d364 100644 --- a/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt +++ b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt @@ -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 diff --git a/app/src/main/java/im/vector/riotredesign/features/home/AvatarRenderer.kt b/app/src/main/java/im/vector/riotredesign/features/home/AvatarRenderer.kt index 275d7613..55bf748f 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/AvatarRenderer.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/AvatarRenderer.kt @@ -90,7 +90,7 @@ object AvatarRenderer { // PRIVATE API ********************************************************************************* private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest { - val resolvedUrl = Matrix.getInstance().currentSession + val resolvedUrl = Matrix.getInstance().currentSession!! .contentUrlResolver() .resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt index 1f72d382..c1a4fef0 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt @@ -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() return HomeActivityViewModel(state, session, roomSelectionRepository) } diff --git a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt index 799818b6..9998e1be 100644 --- a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt +++ b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt @@ -63,8 +63,7 @@ class LoginActivity : RiotActivity() { progressBar.visibility = View.VISIBLE authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback { override fun onSuccess(data: Session) { - Matrix.getInstance().currentSession = data - Matrix.getInstance().currentSession.open() + Matrix.getInstance().currentSession = data.apply { open() } goToHome() } diff --git a/app/src/main/java/im/vector/riotredesign/features/media/MediaContentRenderer.kt b/app/src/main/java/im/vector/riotredesign/features/media/MediaContentRenderer.kt index 86501199..6af33070 100644 --- a/app/src/main/java/im/vector/riotredesign/features/media/MediaContentRenderer.kt +++ b/app/src/main/java/im/vector/riotredesign/features/media/MediaContentRenderer.kt @@ -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( diff --git a/app/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt b/app/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt index 5f82cc97..35122a42 100755 --- a/app/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt +++ b/app/src/main/java/im/vector/riotredesign/features/rageshake/BugReporter.kt @@ -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() if (withDevicesLogs) { - val files = VectorFileLogger.addLogFiles(ArrayList()) + 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)) diff --git a/app/src/main/java/im/vector/riotredesign/features/rageshake/VectorFileLogger.kt b/app/src/main/java/im/vector/riotredesign/features/rageshake/VectorFileLogger.kt index 162a0ed4..e6b17cd8 100644 --- a/app/src/main/java/im/vector/riotredesign/features/rageshake/VectorFileLogger.kt +++ b/app/src/main/java/im/vector/riotredesign/features/rageshake/VectorFileLogger.kt @@ -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): List { + fun getLogFiles(): List { + val files = ArrayList() + try { // reported by GA if (null != sFileHandler) { diff --git a/app/src/main/java/im/vector/riotredesign/features/settings/FontScale.kt b/app/src/main/java/im/vector/riotredesign/features/settings/FontScale.kt index 2cd74ebe..ad8a4506 100644 --- a/app/src/main/java/im/vector/riotredesign/features/settings/FontScale.kt +++ b/app/src/main/java/im/vector/riotredesign/features/settings/FontScale.kt @@ -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 diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index 67f86d82..789fa63f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -39,9 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean class Matrix private constructor(context: Context) : MatrixKoinComponent { private val authenticator by inject() - private val userAgent by inject() + private val userAgentHolder by inject() private val backgroundDetectionObserver by inject() - 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)