Skip to content

Commit b09a24b

Browse files
Fix style behaviour (#6419)
Co-authored-by: Paul Campbell <paulcam@microsoft.com>
1 parent 56b7377 commit b09a24b

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/ColumnRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public View render(
165165
ContainerRenderer.applyVerticalContentAlignment(columnLayout, column.GetVerticalContentAlignment());
166166

167167
ContainerRenderer.applyPadding(styleForThis, renderArgs.getContainerStyle(), columnLayout, hostConfig);
168-
ContainerRenderer.applyContainerStyle(styleForThis, columnLayout, hostConfig);
168+
ContainerRenderer.applyContainerStyle(styleForThis, renderArgs.getContainerStyle(), columnLayout, hostConfig);
169169
ContainerRenderer.applyBleed(column, columnLayout, context, hostConfig);
170170
BaseCardElementRenderer.applyRtl(column.GetRtl(), columnLayout);
171171

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/ColumnSetRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public View render(
132132
columnSetLayout.setTag(tagContent);
133133

134134
ContainerRenderer.applyPadding(styleForThis, parentContainerStyle, columnSetLayout, hostConfig);
135-
ContainerRenderer.applyContainerStyle(styleForThis, columnSetLayout, hostConfig);
135+
ContainerRenderer.applyContainerStyle(styleForThis, parentContainerStyle, columnSetLayout, hostConfig);
136136
ContainerRenderer.applyBleed(columnSet, columnSetLayout, context, hostConfig);
137137

138138
return columnSetLayout;

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/ContainerRenderer.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public View render(
8686
ContainerStyle containerStyle = renderArgs.getContainerStyle();
8787
ContainerStyle styleForThis = getLocalContainerStyle(container, containerStyle);
8888
applyPadding(styleForThis, containerStyle, containerView, hostConfig);
89-
applyContainerStyle(styleForThis, containerView, hostConfig);
89+
applyContainerStyle(styleForThis, containerStyle, containerView, hostConfig);
9090
applyBleed(container, containerView, context, hostConfig);
9191
BaseCardElementRenderer.applyRtl(container.GetRtl(), containerView);
9292

@@ -189,7 +189,7 @@ public static void applyBleed(CollectionTypeElement collectionElement, ViewGroup
189189
public static void ApplyPadding(ContainerStyle computedContainerStyle, ContainerStyle parentContainerStyle, ViewGroup collectionElementView, HostConfig hostConfig)
190190
{
191191
applyPadding(computedContainerStyle, parentContainerStyle, collectionElementView, hostConfig);
192-
applyContainerStyle(computedContainerStyle, collectionElementView, hostConfig);
192+
applyContainerStyle(computedContainerStyle, parentContainerStyle, collectionElementView, hostConfig);
193193
}
194194

195195
public static void applyPadding(ContainerStyle computedContainerStyle, ContainerStyle parentContainerStyle, ViewGroup collectionElementView, HostConfig hostConfig)
@@ -206,16 +206,20 @@ public static void applyPadding(ContainerStyle computedContainerStyle, Container
206206
}
207207
}
208208

209-
public static void applyContainerStyle(ContainerStyle computedContainerStyle, ViewGroup collectionElementView, HostConfig hostConfig)
209+
public static void applyContainerStyle(ContainerStyle computedContainerStyle, ContainerStyle parentContainerStyle, ViewGroup collectionElementView, HostConfig hostConfig)
210210
{
211-
int color = Color.parseColor(hostConfig.GetBackgroundColor(computedContainerStyle));
212-
if (collectionElementView.getBackground() instanceof GradientDrawable)
211+
if (computedContainerStyle != parentContainerStyle)
213212
{
214-
((GradientDrawable) collectionElementView.getBackground()).setColor(color);
215-
}
216-
else
217-
{
218-
collectionElementView.setBackgroundColor(color);
213+
String backgroundColor = hostConfig.GetBackgroundColor(computedContainerStyle);
214+
int color = Color.parseColor(backgroundColor);
215+
if (collectionElementView.getBackground() instanceof GradientDrawable)
216+
{
217+
((GradientDrawable) collectionElementView.getBackground()).setColor(color);
218+
}
219+
else
220+
{
221+
collectionElementView.setBackgroundColor(color);
222+
}
219223
}
220224
}
221225

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/TableCellRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object TableCellRenderer : BaseCardElementRenderer() {
5454

5555
val computedStyle = ContainerRenderer.getLocalContainerStyle(cell, renderArgs.containerStyle)
5656
ContainerRenderer.applyPadding(computedStyle, renderArgs.containerStyle, cellLayout, hostConfig, renderArgs.table.GetShowGridLines())
57-
ContainerRenderer.applyContainerStyle(computedStyle, cellLayout, hostConfig)
57+
ContainerRenderer.applyContainerStyle(computedStyle, renderArgs.containerStyle, cellLayout, hostConfig)
5858
ContainerRenderer.applyVerticalContentAlignment(cellLayout,
5959
computeVerticalContentAlignment(cell.GetVerticalContentAlignment(), row, col, renderArgs.table))
6060
ContainerRenderer.setSelectAction(renderedCard, cell.GetSelectAction(), cellLayout, cardActionHandler, renderArgs)

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/TableRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object TableRenderer : BaseCardElementRenderer() {
4141
clipToPadding = false
4242
}
4343
val rowStyle = ContainerRenderer.computeContainerStyle(row.GetStyle(), renderArgs.containerStyle)
44-
ContainerRenderer.applyContainerStyle(rowStyle, rowLayout, hostConfig)
44+
ContainerRenderer.applyContainerStyle(rowStyle, renderArgs.containerStyle, rowLayout, hostConfig)
4545

4646
for (j in table.GetColumns().indices) {
4747
val cell = row.GetCells().getOrNull(j) ?: break

0 commit comments

Comments
 (0)