-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Table element support #5860
Conversation
.../android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/TableCellRenderer.kt
Show resolved
Hide resolved
.../android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/TableCellRenderer.kt
Outdated
Show resolved
Hide resolved
*/ | ||
public HorizontalAlignment getHorizontalAlignment() | ||
{ | ||
return m_horizontalAlignment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is horizontal alignment passed down as part of the RenderArgs, do table or other containers pass down the property to their child elements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set horizontalCellContentAlignment
on table and table row. Per the spec, this property changes the horizontal alignment of the cell's elements (specifically, TextBlock
, Image
, and RichTextBlock
, which all have a horizontalAlignment
property)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are other Container
elements going to have the same property at some point of the future or is this only planned for table cells?
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
implementation 'androidx.appcompat:appcompat:1.0.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'com.google.android:flexbox:1.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
implementation "androidx.core:core-ktx:1.5.0-rc02" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the use of Kotlin required/necessary for any piece of implementation or is it only used because it's easier to implement with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not required. As our partners use Kotlin, we can start to leverage features to make a better API (e.g. marking some fields as internal
instead of making everything public
, marking required parameters for null safety, etc.). So, for the two new classes here, I've used Kotlin to kickstart that migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case of APIs, are java and kotlin interchangeable? would there be any breaking changes if we fully migrate to kotlin?
@@ -6,7 +6,9 @@ | |||
|
|||
using namespace AdaptiveCards; | |||
|
|||
CollectionTypeElement::CollectionTypeElement(CardElementType type, ContainerStyle style, VerticalContentAlignment alignment) : | |||
CollectionTypeElement::CollectionTypeElement(CardElementType type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the object model changes in their own PR? I feel like reviewing those changes by themselves could be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are in their own PR (created separately). Once that is merged, this PR should stop showing those in the diff.
@@ -1,25 +0,0 @@ | |||
// Top-level build file where you can add configuration options common to all sub-projects/modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this file being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was playing around with .kts version, but decided against it. This didn't get re-added because of gitignore.
source/android/settings.gradle
Outdated
@@ -1 +0,0 @@ | |||
include ':mobilechatapp', ':mobile', ':adaptivecards' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with this one
layoutParams = TableRow.LayoutParams(0, TableLayout.LayoutParams.MATCH_PARENT) | ||
} | ||
|
||
cellLayout.updateLayoutParams<ViewGroup.MarginLayoutParams> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you could move this part to a new method it could be really good for readability, this render method is almost 100 lines long
@@ -156,4 +157,17 @@ public void handleTag(boolean opening, String tag, Editable output, XMLReader xm | |||
} | |||
} | |||
} | |||
|
|||
static HorizontalAlignment computeHorizontalAlignment(RenderArgs renderArgs, HorizontalAlignment declaredAlignment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getHorizontalAlignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above. get/set should be reserved for "property"-like accessors/setters
@@ -46,14 +46,14 @@ public static FactSetRenderer getInstance() | |||
return s_instance; | |||
} | |||
|
|||
static TextView createTextView(Context context, CharSequence text, FactSetTextConfig textConfig, HostConfig hostConfig, long spacing, ContainerStyle containerStyle) | |||
static TextView createTextView(Context context, RenderArgs renderArgs, CharSequence text, FactSetTextConfig textConfig, HostConfig hostConfig, long spacing, ContainerStyle containerStyle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as previously, I think moving RenderArgs as the last parameter may make more sense consistency wise
* @param inherited the ContainerStyle inherited through RenderArgs provided by parent | ||
* @return the ContainerStyle to apply | ||
*/ | ||
public static ContainerStyle computeContainerStyle(ContainerStyle declared, ContainerStyle inherited) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getContainerStyle
applyPadding(computedContainerStyle, parentContainerStyle, collectionElementView, hostConfig, false); | ||
} | ||
|
||
public static void applyPadding(ContainerStyle computedContainerStyle, ContainerStyle parentContainerStyle, ViewGroup collectionElementView, HostConfig hostConfig, boolean hasBorder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may have to figure out at some point if we want static methods to start with a lower case or an upper case letter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java/Kotlin convention is to start with lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got confused because of the deprecated method above
* Kotlin support * Table renderer * Fix style inheriting * Re-SWIG after merge * [Shared] Optional HorizontalAlignment, VerticalContentAlignment * Re-swig * PR feedback * Remove file * Remove file * Update Android tests * Fix iOS build * value_or for iOS * Restore .gradle files * Move RenderArgs to the end * PR feedback refactoring, move to stable kotlin lib version
* Kotlin support * Table renderer * Fix style inheriting * Re-SWIG after merge * [Shared] Optional HorizontalAlignment, VerticalContentAlignment * Re-swig * PR feedback * Remove file * Remove file * Update Android tests * Fix iOS build * value_or for iOS * Restore .gradle files * Move RenderArgs to the end * PR feedback refactoring, move to stable kotlin lib version
Related Issue
Fixes #5725
Description
Table
,TableCell
renderers implemented in Kotlin, andTableCellRenderArgs : RenderArgs
for passing context to cell rendererContainerRenderer.ApplyPadding
was doing two things, so it is now separated intoapplyPadding
andapplyContainerStyle
Sample Card
v1.5\Elements\Table
Added
v1.5\Tests\ColumnSetTableComparison
How Verified
Manual verification
Microsoft Reviewers: Open in CodeFlow