Move rageshake configuration from resource file to Kotlin RageshakeConfig
This commit is contained in:
committed by
Benoit Marty
parent
c58953c639
commit
a6fe0ddc9b
1
.idea/dictionaries/shared.xml
generated
1
.idea/dictionaries/shared.xml
generated
@@ -13,6 +13,7 @@
|
||||
<w>onboarding</w>
|
||||
<w>placeables</w>
|
||||
<w>posthog</w>
|
||||
<w>rageshake</w>
|
||||
<w>securebackup</w>
|
||||
<w>showkase</w>
|
||||
<w>snackbar</w>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 io.element.android.appconfig
|
||||
|
||||
object RageshakeConfig {
|
||||
const val BUG_REPORT_URL = "https://riot.im/bugreports/submit"
|
||||
const val BUG_REPORT_APP_NAME = "element-x-android"
|
||||
}
|
||||
@@ -22,11 +22,11 @@ import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.appconfig.ApplicationConfig
|
||||
import io.element.android.appconfig.RageshakeConfig
|
||||
import io.element.android.features.rageshake.api.crash.CrashDataStore
|
||||
import io.element.android.features.rageshake.api.reporter.BugReporter
|
||||
import io.element.android.features.rageshake.api.reporter.BugReporterListener
|
||||
import io.element.android.features.rageshake.api.screenshot.ScreenshotHolder
|
||||
import io.element.android.features.rageshake.impl.R
|
||||
import io.element.android.libraries.androidutils.file.compressFile
|
||||
import io.element.android.libraries.androidutils.file.safeDelete
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
@@ -139,7 +139,7 @@ class DefaultBugReporter @Inject constructor(
|
||||
// build the multi part request
|
||||
val builder = BugReporterMultipartBody.Builder()
|
||||
.addFormDataPart("text", bugDescription)
|
||||
.addFormDataPart("app", context.getString(R.string.bug_report_app_name))
|
||||
.addFormDataPart("app", RageshakeConfig.BUG_REPORT_APP_NAME)
|
||||
.addFormDataPart("user_agent", userAgentProvider.provide())
|
||||
.addFormDataPart("user_id", userId?.toString() ?: "undefined")
|
||||
.addFormDataPart("can_contact", canContact.toString())
|
||||
|
||||
@@ -17,18 +17,16 @@
|
||||
package io.element.android.features.rageshake.impl.reporter
|
||||
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.features.rageshake.impl.R
|
||||
import io.element.android.appconfig.RageshakeConfig
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultBugReporterUrlProvider @Inject constructor(
|
||||
private val stringProvider: StringProvider
|
||||
) : BugReporterUrlProvider {
|
||||
override fun provide(): HttpUrl {
|
||||
return stringProvider.getString(R.string.bug_report_url).toHttpUrl()
|
||||
return RageshakeConfig.BUG_REPORT_URL.toHttpUrl()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2022 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Rageshake configuration -->
|
||||
<string name="bug_report_url" translatable="false">https://riot.im/bugreports/submit</string>
|
||||
<!--
|
||||
As per https://github.com/matrix-org/rageshake
|
||||
bug_report_app_name: Identifier for the application (eg 'riot-web').
|
||||
Should correspond to a mapping configured in the configuration file for github issue reporting to work.
|
||||
-->
|
||||
<string name="bug_report_app_name" translatable="false">element-x-android</string>
|
||||
|
||||
|
||||
</resources>
|
||||
@@ -17,15 +17,15 @@
|
||||
package io.element.android.features.rageshake.impl.reporter
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import io.element.android.appconfig.RageshakeConfig
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import org.junit.Test
|
||||
|
||||
class DefaultBugReporterUrlProviderTest {
|
||||
@Test
|
||||
fun `test DefaultBugReporterUrlProvider`() {
|
||||
val sut = DefaultBugReporterUrlProvider(FakeStringProvider("https://example.org"))
|
||||
val sut = DefaultBugReporterUrlProvider()
|
||||
val result = sut.provide()
|
||||
assertThat(result).isEqualTo("https://example.org".toHttpUrl())
|
||||
assertThat(result).isEqualTo(RageshakeConfig.BUG_REPORT_URL.toHttpUrl())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user