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:
committed by
GitHub
parent
3e9f8bd024
commit
47f7f8952b
1
changelog.d/2316.bugfix
Normal file
1
changelog.d/2316.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Add missing device id to settings screen.
|
||||
@@ -99,6 +99,7 @@ class PreferencesRootPresenter @Inject constructor(
|
||||
return PreferencesRootState(
|
||||
myUser = matrixUser.value,
|
||||
version = versionFormatter.get(),
|
||||
deviceId = matrixClient.deviceId,
|
||||
showCompleteVerification = showCompleteVerification,
|
||||
showSecureBackup = !showCompleteVerification && secureStorageFlag == true,
|
||||
showSecureBackupBadge = showSecureBackupIndicator,
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
data class PreferencesRootState(
|
||||
val myUser: MatrixUser?,
|
||||
val version: String,
|
||||
val deviceId: String?,
|
||||
val showCompleteVerification: Boolean,
|
||||
val showSecureBackup: Boolean,
|
||||
val showSecureBackupBadge: Boolean,
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
||||
fun aPreferencesRootState() = PreferencesRootState(
|
||||
myUser = null,
|
||||
version = "Version 1.1 (1)",
|
||||
deviceId = "ILAKNDNASDLK",
|
||||
showCompleteVerification = true,
|
||||
showSecureBackup = true,
|
||||
showSecureBackupBadge = true,
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.InsertChart
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -164,18 +165,38 @@ fun PreferencesRootView(
|
||||
style = ListItemStyle.Destructive,
|
||||
onClick = onSignOutClicked,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 40.dp, bottom = 24.dp),
|
||||
textAlign = TextAlign.Center,
|
||||
text = state.version,
|
||||
style = ElementTheme.typography.fontBodySmRegular,
|
||||
color = ElementTheme.materialColors.secondary,
|
||||
Footer(
|
||||
version = state.version,
|
||||
deviceId = state.deviceId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
private fun DeveloperPreferencesView(onOpenDeveloperSettings: () -> Unit) {
|
||||
ListItem(
|
||||
|
||||
@@ -42,7 +42,7 @@ class DefaultVersionFormatter @Inject constructor(
|
||||
base
|
||||
} else {
|
||||
// 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})"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class PreferencesRootPresenterTest {
|
||||
directLogoutPresenter = object : DirectLogoutPresenter {
|
||||
@Composable
|
||||
override fun present() = aDirectLogoutState
|
||||
}
|
||||
},
|
||||
)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
|
||||
@@ -41,7 +41,7 @@ class VersionFormatterTest {
|
||||
gitRevision = "1234567890",
|
||||
)
|
||||
)
|
||||
assertThat(sut.get()).isEqualTo("$VERSION\nbranch\n1234567890")
|
||||
assertThat(sut.get()).isEqualTo("$VERSION\nbranch (1234567890)")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.io.Closeable
|
||||
|
||||
interface MatrixClient : Closeable {
|
||||
val sessionId: SessionId
|
||||
val deviceId: String
|
||||
val roomListService: RoomListService
|
||||
val mediaLoader: MatrixMediaLoader
|
||||
val sessionCoroutineScope: CoroutineScope
|
||||
|
||||
@@ -102,6 +102,7 @@ class RustMatrixClient(
|
||||
private val clock: SystemClock,
|
||||
) : MatrixClient {
|
||||
override val sessionId: UserId = UserId(client.userId())
|
||||
override val deviceId: String = client.deviceId()
|
||||
override val sessionCoroutineScope = appCoroutineScope.childScope(dispatchers.main, "Session-$sessionId")
|
||||
|
||||
private val innerRoomListService = syncService.roomListService()
|
||||
|
||||
@@ -49,6 +49,7 @@ import kotlinx.coroutines.test.TestScope
|
||||
|
||||
class FakeMatrixClient(
|
||||
override val sessionId: SessionId = A_SESSION_ID,
|
||||
override val deviceId: String = "A_DEVICE_ID",
|
||||
override val sessionCoroutineScope: CoroutineScope = TestScope(),
|
||||
private val userDisplayName: Result<String> = Result.success(A_USER_NAME),
|
||||
private val userAvatarUrl: Result<String> = Result.success(AN_AVATAR_URL),
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
|
||||
|
||||
class ComponentTestPreview(
|
||||
@@ -27,6 +28,10 @@ class ComponentTestPreview(
|
||||
|
||||
override val name: String = showkaseBrowserComponent.componentName
|
||||
|
||||
override fun customHeightDp(): Dp? {
|
||||
return showkaseBrowserComponent.heightDp?.let { Dp(it.toFloat()) }
|
||||
}
|
||||
|
||||
override fun toString(): String = showkaseBrowserComponent.componentKey
|
||||
// Strip common package beginning
|
||||
.replace("io.element.android.features.", "f.")
|
||||
|
||||
@@ -94,6 +94,8 @@ class S {
|
||||
) {
|
||||
val locale = localeStr.toLocale()
|
||||
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(
|
||||
deviceConfig = baseDeviceConfig.deviceConfig.copy(
|
||||
softButtons = false,
|
||||
@@ -104,6 +106,7 @@ class S {
|
||||
false -> NightMode.NOTNIGHT
|
||||
}
|
||||
},
|
||||
screenHeight = customScreenHeight ?: baseDeviceConfig.deviceConfig.screenHeight,
|
||||
),
|
||||
)
|
||||
paparazzi.snapshot {
|
||||
|
||||
@@ -18,6 +18,7 @@ package ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import com.airbnb.android.showkase.models.ShowkaseElementsMetadata
|
||||
import io.element.android.libraries.designsystem.preview.NIGHT_MODE_NAME
|
||||
|
||||
@@ -26,6 +27,8 @@ interface TestPreview {
|
||||
fun Content()
|
||||
|
||||
val name: String
|
||||
|
||||
fun customHeightDp(): Dp? = null
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user