Element config (#4471)

* Add handy extension "VariantDimension.buildConfigFieldStr"

* Update configuration for MapTiler.

* Update configuration for Sentry.

* Build AnalyticsConfig depending on analytics configuration.

* Configure analytics policy url.

* Add handy extension "VariantDimension.buildConfigFieldBoolean"

* Configure legal urls.

* Add a way to disable rageshake / reporting bugs.

* Update screenshots

* Quality

* Fix test

* Use `ifBlank` extension

* Add missing configuration for PostHog

* Update configuration for Rageshake.

* Add build log.

* Disable crash detection if rageshake feature is not available.
Disabled twice.

* Hide link to analytics policy if the link is missing.

* Fix test when run in enterprise context.

* Use RageshakeFeatureAvailability where appropriate.

* Rename file.

* Move some classes to their correct module.

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
Benoit Marty 2025-03-27 11:25:04 +01:00 committed by GitHub
parent c6b99c853c
commit 3c1deff79c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
95 changed files with 613 additions and 273 deletions

View file

@ -0,0 +1,12 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.api
fun interface RageshakeFeatureAvailability {
fun isAvailable(): Boolean
}

View file

@ -1,20 +0,0 @@
/*
* Copyright 2023, 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.api.crash
import kotlinx.coroutines.flow.Flow
interface CrashDataStore {
fun setCrashData(crashData: String)
suspend fun resetAppHasCrashed()
fun appHasCrashed(): Flow<Boolean>
fun crashInfo(): Flow<String>
suspend fun reset()
}

View file

@ -8,6 +8,7 @@
package io.element.android.features.rageshake.api.preferences
data class RageshakePreferencesState(
val isFeatureEnabled: Boolean,
val isEnabled: Boolean,
val isSupported: Boolean,
val sensitivity: Float,

View file

@ -12,14 +12,21 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
open class RageshakePreferencesStateProvider : PreviewParameterProvider<RageshakePreferencesState> {
override val values: Sequence<RageshakePreferencesState>
get() = sequenceOf(
aRageshakePreferencesState().copy(isEnabled = true, isSupported = true, sensitivity = 0.5f),
aRageshakePreferencesState().copy(isEnabled = true, isSupported = false, sensitivity = 0.5f),
aRageshakePreferencesState(isEnabled = true, isSupported = true, sensitivity = 0.5f),
aRageshakePreferencesState(isEnabled = true, isSupported = false, sensitivity = 0.5f),
)
}
fun aRageshakePreferencesState() = RageshakePreferencesState(
isEnabled = false,
isSupported = true,
sensitivity = 0.3f,
eventSink = {}
fun aRageshakePreferencesState(
isFeatureEnabled: Boolean = true,
isEnabled: Boolean = false,
isSupported: Boolean = true,
sensitivity: Float = 0.3f,
eventSink: (RageshakePreferencesEvents) -> Unit = {}
) = RageshakePreferencesState(
isFeatureEnabled = isFeatureEnabled,
isEnabled = isEnabled,
isSupported = isSupported,
sensitivity = sensitivity,
eventSink = eventSink,
)

View file

@ -36,28 +36,30 @@ fun RageshakePreferencesView(
}
Column(modifier = modifier) {
PreferenceCategory(title = stringResource(id = R.string.settings_rageshake)) {
if (state.isSupported) {
PreferenceSwitch(
title = stringResource(id = CommonStrings.preference_rageshake),
isChecked = state.isEnabled,
onCheckedChange = ::onEnabledChanged
)
PreferenceSlide(
title = stringResource(id = R.string.settings_rageshake_detection_threshold),
// summary = stringResource(id = CommonStrings.settings_rageshake_detection_threshold_summary),
value = state.sensitivity,
enabled = state.isEnabled,
// 5 possible values - steps are in ]0, 1[
steps = 3,
onValueChange = ::onSensitivityChanged
)
} else {
ListItem(
headlineContent = {
Text("Rageshaking is not supported by your device")
},
)
if (state.isFeatureEnabled) {
PreferenceCategory(title = stringResource(id = R.string.settings_rageshake)) {
if (state.isSupported) {
PreferenceSwitch(
title = stringResource(id = CommonStrings.preference_rageshake),
isChecked = state.isEnabled,
onCheckedChange = ::onEnabledChanged
)
PreferenceSlide(
title = stringResource(id = R.string.settings_rageshake_detection_threshold),
// summary = stringResource(id = CommonStrings.settings_rageshake_detection_threshold_summary),
value = state.sensitivity,
enabled = state.isEnabled,
// 5 possible values - steps are in ]0, 1[
steps = 3,
onValueChange = ::onSensitivityChanged
)
} else {
ListItem(
headlineContent = {
Text("Rageshaking is not supported by your device")
},
)
}
}
}
}

View file

@ -1,27 +0,0 @@
/*
* Copyright 2023, 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.api.rageshake
interface RageShake {
/**
* Check if the feature is available on this device.
*/
fun isAvailable(): Boolean
fun start(sensitivity: Float)
fun stop()
/**
* sensitivity will be {0, O.25, 0.5, 0.75, 1} and converted to
* [ShakeDetector.SENSITIVITY_LIGHT (=11), ShakeDetector.SENSITIVITY_HARD (=15)].
*/
fun setSensitivity(sensitivity: Float)
fun setInterceptor(interceptor: (() -> Unit)?)
}

View file

@ -1,22 +0,0 @@
/*
* Copyright 2023, 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.api.rageshake
import kotlinx.coroutines.flow.Flow
interface RageshakeDataStore {
fun isEnabled(): Flow<Boolean>
suspend fun setIsEnabled(isEnabled: Boolean)
fun sensitivity(): Flow<Float>
suspend fun setSensitivity(sensitivity: Float)
suspend fun reset()
}

View file

@ -1,16 +0,0 @@
/*
* Copyright 2023, 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.api.screenshot
import android.graphics.Bitmap
interface ScreenshotHolder {
fun writeBitmap(data: Bitmap)
fun getFileUri(): String?
fun reset()
}