Add server version in rageshakes
This commit is contained in:
parent
531beb0a86
commit
b8ba463735
|
@ -21,12 +21,15 @@ import android.view.MenuItem
|
|||
import android.widget.Toast
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.airbnb.mvrx.viewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivityBugReportBinding
|
||||
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Form to send a bug report
|
||||
|
@ -39,6 +42,10 @@ class BugReportActivity : VectorBaseActivity<ActivityBugReportBinding>() {
|
|||
|
||||
override fun getBinding() = ActivityBugReportBinding.inflate(layoutInflater)
|
||||
|
||||
@Inject lateinit var bugReportViewModelFactory: BugReportViewModel.Factory
|
||||
|
||||
private val viewModel: BugReportViewModel by viewModel()
|
||||
|
||||
private var forSuggestion: Boolean = false
|
||||
|
||||
override fun initUiAndData() {
|
||||
|
@ -114,7 +121,7 @@ class BugReportActivity : VectorBaseActivity<ActivityBugReportBinding>() {
|
|||
/**
|
||||
* Send the bug report
|
||||
*/
|
||||
private fun sendBugReport() {
|
||||
private fun sendBugReport() = withState(viewModel) { state ->
|
||||
views.bugReportScrollview.alpha = 0.3f
|
||||
views.bugReportMaskView.isVisible = true
|
||||
|
||||
|
@ -133,6 +140,7 @@ class BugReportActivity : VectorBaseActivity<ActivityBugReportBinding>() {
|
|||
views.bugReportButtonIncludeKeyShareHistory.isChecked,
|
||||
views.bugReportButtonIncludeScreenshot.isChecked,
|
||||
views.bugReportEditText.text.toString(),
|
||||
state.serverVersion,
|
||||
object : BugReporter.IMXBugReportListener {
|
||||
override fun onUploadFailed(reason: String?) {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 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.rageshake
|
||||
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
|
||||
data class BugReportState(
|
||||
val serverVersion: String = ""
|
||||
) : MvRxState
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 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.rageshake
|
||||
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.ActivityViewModelContext
|
||||
import com.airbnb.mvrx.MvRxViewModelFactory
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.platform.EmptyAction
|
||||
import im.vector.app.core.platform.EmptyViewEvents
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
|
||||
class BugReportViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: BugReportState,
|
||||
val activeSessionHolder: ActiveSessionHolder
|
||||
) : VectorViewModel<BugReportState, EmptyAction, EmptyViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: BugReportState): BugReportViewModel
|
||||
}
|
||||
|
||||
companion object : MvRxViewModelFactory<BugReportViewModel, BugReportState> {
|
||||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: BugReportState): BugReportViewModel? {
|
||||
val activity: BugReportActivity = (viewModelContext as ActivityViewModelContext).activity()
|
||||
return activity.bugReportViewModelFactory.create(state)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
fetchHomeserverVersion()
|
||||
}
|
||||
|
||||
private fun fetchHomeserverVersion() {
|
||||
viewModelScope.launch {
|
||||
val version = tryOrNull {
|
||||
activeSessionHolder.getSafeActiveSession()
|
||||
?.federationService()
|
||||
?.getFederationVersion()
|
||||
?.let { "${it.name} - ${it.version}" }
|
||||
} ?: "undefined"
|
||||
|
||||
setState {
|
||||
copy(
|
||||
serverVersion = version
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun handle(action: EmptyAction) {
|
||||
// No op
|
||||
}
|
||||
}
|
|
@ -165,6 +165,7 @@ class BugReporter @Inject constructor(
|
|||
withKeyRequestHistory: Boolean,
|
||||
withScreenshot: Boolean,
|
||||
theBugDescription: String,
|
||||
serverVersion: String,
|
||||
listener: IMXBugReportListener?) {
|
||||
// enumerate files to delete
|
||||
val mBugReportFiles: MutableList<File> = ArrayList()
|
||||
|
@ -273,6 +274,7 @@ class BugReporter @Inject constructor(
|
|||
.addFormDataPart("app_language", VectorLocale.applicationLocale.toString())
|
||||
.addFormDataPart("default_app_language", systemLocaleProvider.getSystemLocale().toString())
|
||||
.addFormDataPart("theme", ThemeUtils.getApplicationTheme(context))
|
||||
.addFormDataPart("server_version", serverVersion)
|
||||
|
||||
val buildNumber = context.getString(R.string.build_number)
|
||||
if (buildNumber.isNotEmpty() && buildNumber != "0") {
|
||||
|
|
Loading…
Reference in New Issue