Add missing device id to settings screen (#2320)

* Add missing device id to settings screen

* Extract footer component

* Restore `@PreviewWithLargeHeight` logic

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-01-31 11:01:17 +01:00 committed by GitHub
parent 3e9f8bd024
commit 47f7f8952b
50 changed files with 122 additions and 83 deletions

1
changelog.d/2316.bugfix Normal file
View file

@ -0,0 +1 @@
Add missing device id to settings screen.

View file

@ -99,6 +99,7 @@ class PreferencesRootPresenter @Inject constructor(
return PreferencesRootState( return PreferencesRootState(
myUser = matrixUser.value, myUser = matrixUser.value,
version = versionFormatter.get(), version = versionFormatter.get(),
deviceId = matrixClient.deviceId,
showCompleteVerification = showCompleteVerification, showCompleteVerification = showCompleteVerification,
showSecureBackup = !showCompleteVerification && secureStorageFlag == true, showSecureBackup = !showCompleteVerification && secureStorageFlag == true,
showSecureBackupBadge = showSecureBackupIndicator, showSecureBackupBadge = showSecureBackupIndicator,

View file

@ -23,6 +23,7 @@ import io.element.android.libraries.matrix.api.user.MatrixUser
data class PreferencesRootState( data class PreferencesRootState(
val myUser: MatrixUser?, val myUser: MatrixUser?,
val version: String, val version: String,
val deviceId: String?,
val showCompleteVerification: Boolean, val showCompleteVerification: Boolean,
val showSecureBackup: Boolean, val showSecureBackup: Boolean,
val showSecureBackupBadge: Boolean, val showSecureBackupBadge: Boolean,

View file

@ -24,6 +24,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
fun aPreferencesRootState() = PreferencesRootState( fun aPreferencesRootState() = PreferencesRootState(
myUser = null, myUser = null,
version = "Version 1.1 (1)", version = "Version 1.1 (1)",
deviceId = "ILAKNDNASDLK",
showCompleteVerification = true, showCompleteVerification = true,
showSecureBackup = true, showSecureBackup = true,
showSecureBackupBadge = true, showSecureBackupBadge = true,

View file

@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.InsertChart import androidx.compose.material.icons.outlined.InsertChart
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
@ -164,18 +165,38 @@ fun PreferencesRootView(
style = ListItemStyle.Destructive, style = ListItemStyle.Destructive,
onClick = onSignOutClicked, onClick = onSignOutClicked,
) )
Text( Footer(
modifier = Modifier version = state.version,
.fillMaxWidth() deviceId = state.deviceId,
.padding(top = 40.dp, bottom = 24.dp),
textAlign = TextAlign.Center,
text = state.version,
style = ElementTheme.typography.fontBodySmRegular,
color = ElementTheme.materialColors.secondary,
) )
} }
} }
@Composable
private fun Footer(
version: String,
deviceId: String?
) {
val text = remember(version, deviceId) {
buildString {
append(version)
if (deviceId != null) {
append("\n")
append(deviceId)
}
}
}
Text(
modifier = Modifier
.fillMaxWidth()
.padding(top = 40.dp, bottom = 24.dp),
textAlign = TextAlign.Center,
text = text,
style = ElementTheme.typography.fontBodySmRegular,
color = ElementTheme.materialColors.secondary,
)
}
@Composable @Composable
private fun DeveloperPreferencesView(onOpenDeveloperSettings: () -> Unit) { private fun DeveloperPreferencesView(onOpenDeveloperSettings: () -> Unit) {
ListItem( ListItem(

View file

@ -42,7 +42,7 @@ class DefaultVersionFormatter @Inject constructor(
base base
} else { } else {
// In case of a build not from main, we display the branch name and the revision // In case of a build not from main, we display the branch name and the revision
"$base\n${buildMeta.gitBranchName}\n${buildMeta.gitRevision}" "$base\n${buildMeta.gitBranchName} (${buildMeta.gitRevision})"
} }
} }
} }

View file

@ -70,7 +70,7 @@ class PreferencesRootPresenterTest {
directLogoutPresenter = object : DirectLogoutPresenter { directLogoutPresenter = object : DirectLogoutPresenter {
@Composable @Composable
override fun present() = aDirectLogoutState override fun present() = aDirectLogoutState
} },
) )
moleculeFlow(RecompositionMode.Immediate) { moleculeFlow(RecompositionMode.Immediate) {
presenter.present() presenter.present()

View file

@ -41,7 +41,7 @@ class VersionFormatterTest {
gitRevision = "1234567890", gitRevision = "1234567890",
) )
) )
assertThat(sut.get()).isEqualTo("$VERSION\nbranch\n1234567890") assertThat(sut.get()).isEqualTo("$VERSION\nbranch (1234567890)")
} }
companion object { companion object {

View file

@ -39,6 +39,7 @@ import java.io.Closeable
interface MatrixClient : Closeable { interface MatrixClient : Closeable {
val sessionId: SessionId val sessionId: SessionId
val deviceId: String
val roomListService: RoomListService val roomListService: RoomListService
val mediaLoader: MatrixMediaLoader val mediaLoader: MatrixMediaLoader
val sessionCoroutineScope: CoroutineScope val sessionCoroutineScope: CoroutineScope

View file

@ -102,6 +102,7 @@ class RustMatrixClient(
private val clock: SystemClock, private val clock: SystemClock,
) : MatrixClient { ) : MatrixClient {
override val sessionId: UserId = UserId(client.userId()) override val sessionId: UserId = UserId(client.userId())
override val deviceId: String = client.deviceId()
override val sessionCoroutineScope = appCoroutineScope.childScope(dispatchers.main, "Session-$sessionId") override val sessionCoroutineScope = appCoroutineScope.childScope(dispatchers.main, "Session-$sessionId")
private val innerRoomListService = syncService.roomListService() private val innerRoomListService = syncService.roomListService()

View file

@ -49,6 +49,7 @@ import kotlinx.coroutines.test.TestScope
class FakeMatrixClient( class FakeMatrixClient(
override val sessionId: SessionId = A_SESSION_ID, override val sessionId: SessionId = A_SESSION_ID,
override val deviceId: String = "A_DEVICE_ID",
override val sessionCoroutineScope: CoroutineScope = TestScope(), override val sessionCoroutineScope: CoroutineScope = TestScope(),
private val userDisplayName: Result<String> = Result.success(A_USER_NAME), private val userDisplayName: Result<String> = Result.success(A_USER_NAME),
private val userAvatarUrl: Result<String> = Result.success(AN_AVATAR_URL), private val userAvatarUrl: Result<String> = Result.success(AN_AVATAR_URL),

View file

@ -17,6 +17,7 @@
package ui package ui
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.Dp
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
class ComponentTestPreview( class ComponentTestPreview(
@ -27,6 +28,10 @@ class ComponentTestPreview(
override val name: String = showkaseBrowserComponent.componentName override val name: String = showkaseBrowserComponent.componentName
override fun customHeightDp(): Dp? {
return showkaseBrowserComponent.heightDp?.let { Dp(it.toFloat()) }
}
override fun toString(): String = showkaseBrowserComponent.componentKey override fun toString(): String = showkaseBrowserComponent.componentKey
// Strip common package beginning // Strip common package beginning
.replace("io.element.android.features.", "f.") .replace("io.element.android.features.", "f.")

View file

@ -94,6 +94,8 @@ class S {
) { ) {
val locale = localeStr.toLocale() val locale = localeStr.toLocale()
Locale.setDefault(locale) // Needed for regional settings, as first day of week Locale.setDefault(locale) // Needed for regional settings, as first day of week
val densityScale = baseDeviceConfig.deviceConfig.density.dpiValue / 160f
val customScreenHeight = componentTestPreview.customHeightDp()?.value?.let { it * densityScale }?.toInt()
paparazzi.unsafeUpdateConfig( paparazzi.unsafeUpdateConfig(
deviceConfig = baseDeviceConfig.deviceConfig.copy( deviceConfig = baseDeviceConfig.deviceConfig.copy(
softButtons = false, softButtons = false,
@ -104,6 +106,7 @@ class S {
false -> NightMode.NOTNIGHT false -> NightMode.NOTNIGHT
} }
}, },
screenHeight = customScreenHeight ?: baseDeviceConfig.deviceConfig.screenHeight,
), ),
) )
paparazzi.snapshot { paparazzi.snapshot {

View file

@ -18,6 +18,7 @@ package ui
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import com.airbnb.android.showkase.models.ShowkaseElementsMetadata import com.airbnb.android.showkase.models.ShowkaseElementsMetadata
import io.element.android.libraries.designsystem.preview.NIGHT_MODE_NAME import io.element.android.libraries.designsystem.preview.NIGHT_MODE_NAME
@ -26,6 +27,8 @@ interface TestPreview {
fun Content() fun Content()
val name: String val name: String
fun customHeightDp(): Dp? = null
} }
/** /**

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:307c4fe957488e38390e1b0b14458be0551e7b2409b2c9b6b1da3a99f8eae1a6 oid sha256:18a6da77975c5748f650fdfc11d05bdb6db28df4fba132a314edd8fbb0354d90
size 45163 size 36950

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:9c88869958081e9752a1a6b4cf4a0b457b834b72bd691a48c333f5ee9239efbc oid sha256:5dc4cc6825afe60718eb4c19ba2a7269296089e0050e0a361545613913ca3be4
size 44481 size 36594

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f81f3e28243e1d1db8625979d49a9dd29338aac7900f21d1002694b8091d6bb4 oid sha256:2b21a97c05098dfda4e23b670ff122ed2a60040536d599cd8e6921ed9ed4c45f
size 48221 size 38825

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4c0f01d3a1a3cd7845b02dbefef3dbfe564ecc6a19c6a29b598065fe45d5edcd oid sha256:95fdb43e8761a19fed0ff146af3ed87968c78268c37933d014d15afe1401e67d
size 48119 size 38773

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:635af24c8306297ac954aa7ddb4286c36904b763e8f32acbbad841334dda8253 oid sha256:1d8a2dbbe7f9a2f10cd695b98fc0228e4d77733dd5de6c8428fc0cd1b4007ae4
size 22352 size 14486

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c8b5d1c152ed4f3334fc5d6fa74546a1fa7f50dd4975f6f108028a34be0db63c oid sha256:375d40b416b82cf9eb83bd76ff69d3eb13951b58922bd68c705709eb188c5198
size 20248 size 13008

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a7caaac71c2c280fc18036e725d9a64aae77e351b494440bbac6f6776658c856 oid sha256:89e598cde19e3e51a00324b9effcbeac25f82fc21b349f67da03944c1561210d
size 22544 size 14611

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:44e2a0e5c2adb1d80c2bf2abfc3ab481ef28a7dd44de8fcdca73d87933219f65 oid sha256:cb0159f528c7361a9683ddf8ac55d08bc8f0b133c73b31c8268df8d58d0fa53f
size 38735 size 23615

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:29a24d3f9c01d866f2b3cfdff1460a47f956c2b30865f1c0c74a505a7ee40581 oid sha256:b2d39a27cbcdad79313ee165bb1cbf7f161c5e8fefb8fe051f376d5e455cd529
size 30824 size 20320

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:59eeb239a62ee386b9a162bf82fec97e8834ace6ad59b21efd445f9e736b54cf oid sha256:fab48c418797b4985bf3b92aa11663c484fca0289b16c969c85f402342eed145
size 23046 size 14868

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:68ceadfa7696c8350c45bc4c47553e8fe8c10e283ae2a3420a4192160bd97ab7 oid sha256:cabfecdde0ababf6831384589bf0b5bc32629428d61658c60477067d6792140d
size 22925 size 16370

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:52dcc40a72b799510a4400662b462bba34bbb6be98a35eaa5c3edc3a671aa786 oid sha256:dd014eb7241ac06417aa8677bdc2e8f995e31e3c27e979256c63a5e9718c2bfa
size 23016 size 14856

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:6099039f33757df49245866f6dbcca9576b216b1fe9e1f87c6c4f4e92add153c oid sha256:9a4425c47303f82a286e343bd77829793f331de7fb10db50d9c2b7309d98d362
size 20945 size 13260

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:6f5586f7c60ea5959713a66cb97397c5d834b27100e1603bcbb98c430dc0873e oid sha256:2be42690dc43bd5db978cf54ac8182ba4fa009b766528d1141279ee588a2b186
size 23539 size 15103

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:10d2ea969c9cd2bcd809e72cc56d8ae086b1b4d848636c55e9db5ef23783620d oid sha256:61973949f719777b9c28b0657798cd0c745635ce90d2fb9eed17b396b0ec3e79
size 43647 size 26051

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e220d275226ae8820e0119a767b2baf964f2173c430531a379e338bdf9e08adc oid sha256:a7a86733318877c78173c9d837c842657661b19ed7a316dd42b9e5ef1839540b
size 35530 size 23195

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:935e5fe6677faea88995128ce60f3ce014eb6f434f33eff372fce9bb9192d503 oid sha256:8056636bf9a039ae6b0d9dac5a40803de19ca31cb0c48863b894a12886a6ddae
size 24191 size 15405

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1745fbfae1996203b192b07bbbf424eb129944b37b83c0203fcd05c7f332096d oid sha256:d3791d6234a15c1deda513593b19149d97bc1062611eedb108839ba2bf1076eb
size 25874 size 18636

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:703fd7531d62f1fc4be44fd223665abf3a8c533cd473300b605fde27ce72c273 oid sha256:3f92b41af4156789be97ae4e6089e072e6fef5323b9900746ae196ab73d81c9d
size 52403 size 41991

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:345e007ece378018d657a4ee35b2698913cb5e843eeea6c5c511597032979083 oid sha256:0cef80f10d1c5830c6e21da832016d94126add970ccf10adc6f64097184ac6a7
size 48555 size 30360

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:dba006c9bd847ccb9eafd5decd491058016f16dcb1daeed5bc8c142b2d8a6da3 oid sha256:83f7126092b50b8149936f68618bc49ac7af7cadf0ba1179ccf14b70ff93a6cd
size 32717 size 32625

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:703fd7531d62f1fc4be44fd223665abf3a8c533cd473300b605fde27ce72c273 oid sha256:960d3a6a7a47920f9720fac04ee624a102206bdaa763531fd5f7d7aa59914a54
size 52403 size 31932

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:dea742464c55cbb29188c7f944ed68b887daf09429a1c61c6a6d610332749a6c oid sha256:debd7796dd77a861df31f8420fc6f7857da7750f8b301fd1e331c4e6c2250461
size 50212 size 39568

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:fda8d3e0eb21cb9754f93699569acbfc79de6c5ba187528601342a0311f20aa1 oid sha256:3931be400c2610a408686d115cbeac328aa1ac33fe868176e66de460b4182b31
size 47079 size 39791

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:fda8d3e0eb21cb9754f93699569acbfc79de6c5ba187528601342a0311f20aa1 oid sha256:3931be400c2610a408686d115cbeac328aa1ac33fe868176e66de460b4182b31
size 47079 size 39791

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:703fd7531d62f1fc4be44fd223665abf3a8c533cd473300b605fde27ce72c273 oid sha256:467e88bdbaf0df59ab010487f11eb211f7a61a324344cd310b0f44b3ce57e09b
size 52403 size 43412

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:dd08c741a1ac7de4bf60c30b42d9fa085ec4c11a9d95e8988131a4e9215ac88c oid sha256:fb982a239d8d3e5357c1c9e5247cd3a0ddf510f8c2741d9cd02571c53d60bc45
size 52239 size 41833

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f0ba3767a5696b9b57786ac56a8a23828062aaa9ffde62e0f9f3226edcf95841 oid sha256:f3397f850c19ffdb387aaec22fe694077b98e3837571adb03d04dbed1bbab81d
size 53594 size 43153

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a4a2a602f024a9bc0d03aada3c91c1d3013f84bf6de6443ce4b7ce040df0212d oid sha256:7c21afc66bc5536988199efa7f75943f2cd4744548a74b23819a2c3e756fbec9
size 51262 size 31453

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:85b10ff2a36e5bcbf8f24c429be6cb4aac76f9e36a19c4af07534870c6b80d3e oid sha256:d68ef34aa4eadd9219441b8fa762938091861e5a6b54d3d6e0ea0fce0f8cdd03
size 34360 size 34007

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f0ba3767a5696b9b57786ac56a8a23828062aaa9ffde62e0f9f3226edcf95841 oid sha256:82a4be110528c6a3f65b701dd8da370454709c8cdbdb482a5d918c88565e5cfe
size 53594 size 32627

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:319b14b73b8e57004fb8528815ddeacb123f245beee5009831b0f151aab9ad1b oid sha256:fa05421ae0ac8e5ebd9dbeb3839ad0fe042295e2dc8c28b807b7060089d87680
size 51560 size 40740

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:29e8f90bfa5518b8ee35f88a9c40e3cfbd58b3b15e7cf4d94515a50a41ca98fe oid sha256:aacd3606f9cc6416038cdf909b4148a2be59e9669230510c18fa7299145799dd
size 48050 size 40949

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:29e8f90bfa5518b8ee35f88a9c40e3cfbd58b3b15e7cf4d94515a50a41ca98fe oid sha256:aacd3606f9cc6416038cdf909b4148a2be59e9669230510c18fa7299145799dd
size 48050 size 40949

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f0ba3767a5696b9b57786ac56a8a23828062aaa9ffde62e0f9f3226edcf95841 oid sha256:3ce3125399cdbd8865842478b66586dd4641bbfb40b14af20702d23ea73d13a4
size 53594 size 44521

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d3818906c06db9eae696b5891ccdccec16b8b4ed56c2dfaea506656736c2f917 oid sha256:1d2acf4cdf6b23ac6837e48fa3f0175b3e7b20b74ac6e8da3271ef2e80d28749
size 53377 size 43007