Set max lines for 'in reply to' view conditionally (#6612)
* Set max lines for 'in reply to' view conditionally. When there is enough screen space, use 2 lines as before. If the screen space is limited, use a single one. * Reduce vertical padding for reply-to view in compose * Add screenshot test with single line in reply to view * Update screenshots --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
parent
f5da2cf09c
commit
b17388d686
102 changed files with 274 additions and 205 deletions
|
|
@ -22,6 +22,7 @@ import app.cash.paparazzi.DeviceConfig
|
|||
import app.cash.paparazzi.Paparazzi
|
||||
import app.cash.paparazzi.RenderExtension
|
||||
import app.cash.paparazzi.TestName
|
||||
import com.android.resources.Density.DEFAULT_DENSITY
|
||||
import com.android.resources.NightMode
|
||||
import com.android.resources.ScreenOrientation
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
|
@ -42,12 +43,13 @@ object ScreenshotTest {
|
|||
Locale.setDefault(locale)
|
||||
|
||||
paparazzi.fixScreenshotName(preview, localeStr)
|
||||
|
||||
paparazzi.snapshot {
|
||||
CompositionLocalProvider(
|
||||
LocalInspectionMode provides true,
|
||||
LocalDensity provides Density(
|
||||
density = LocalDensity.current.density,
|
||||
fontScale = 1.0f,
|
||||
fontScale = preview.previewInfo.fontScale,
|
||||
),
|
||||
LocalConfiguration provides Configuration().apply {
|
||||
setLocales(LocaleList(locale))
|
||||
|
|
@ -121,19 +123,22 @@ object PaparazziPreviewRule {
|
|||
deviceConfig: DeviceConfig = ScreenshotTest.defaultDeviceConfig,
|
||||
renderExtensions: Set<RenderExtension> = setOf(),
|
||||
): Paparazzi {
|
||||
val densityScale = deviceConfig.density.dpiValue / 160f
|
||||
val densityScale = deviceConfig.density.dpiValue.toFloat() / DEFAULT_DENSITY
|
||||
val customScreenWidth = preview.previewInfo.widthDp.takeIf { it >= 0 }?.let { it * densityScale }?.toInt()
|
||||
val customScreenHeight = preview.previewInfo.heightDp.takeIf { it >= 0 }?.let { it * densityScale }?.toInt()
|
||||
val isLandscape = preview.previewInfo.device.contains("landscape")
|
||||
return Paparazzi(
|
||||
deviceConfig = deviceConfig.copy(
|
||||
screenWidth = customScreenWidth ?: deviceConfig.screenWidth,
|
||||
screenHeight = customScreenHeight ?: deviceConfig.screenHeight,
|
||||
nightMode = when (preview.previewInfo.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) {
|
||||
true -> NightMode.NIGHT
|
||||
false -> NightMode.NOTNIGHT
|
||||
},
|
||||
locale = locale,
|
||||
softButtons = false,
|
||||
screenHeight = customScreenHeight ?: deviceConfig.screenHeight,
|
||||
orientation = if (isLandscape) ScreenOrientation.LANDSCAPE else ScreenOrientation.PORTRAIT,
|
||||
fontScale = preview.previewInfo.fontScale,
|
||||
),
|
||||
maxPercentDifference = 0.01,
|
||||
renderExtensions = renderExtensions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue