Skip to content
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

Merged
merged 24 commits into from
May 27, 2021
Merged

[Android] Table element support #5860

merged 24 commits into from
May 27, 2021

Conversation

golddove
Copy link
Member

@golddove golddove commented May 21, 2021

Related Issue

Fixes #5725

Description

  • Fixed object model to use the appropriate VerticalContentAlignment enum
  • Fixed object model default border color values to remove excess hex characters
  • Added Table, TableCell renderers implemented in Kotlin, and TableCellRenderArgs : RenderArgs for passing context to cell renderer
  • [DEPRECATION] ContainerRenderer.ApplyPadding was doing two things, so it is now separated into applyPadding and applyContainerStyle
  • [TODO] Awaiting host config support for header text style (using heading style instead, for now)

Sample Card

v1.5\Elements\Table
Added v1.5\Tests\ColumnSetTableComparison

How Verified

Manual verification

Microsoft Reviewers: Open in CodeFlow

@ghost ghost removed the Needs: Author Feedback label May 26, 2021
@golddove golddove requested a review from paulcam206 May 26, 2021 15:27
*/
public HorizontalAlignment getHorizontalAlignment()
{
return m_horizontalAlignment;
Copy link
Contributor

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?

Copy link
Member Author

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)

Copy link
Contributor

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"
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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,
Copy link
Contributor

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

Copy link
Member Author

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.
Copy link
Contributor

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?

Copy link
Member Author

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.

@@ -1 +0,0 @@
include ':mobilechatapp', ':mobile', ':adaptivecards'
Copy link
Contributor

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> {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getHorizontalAlignment

Copy link
Member Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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

@ghost ghost removed the Needs: Author Feedback label May 27, 2021
@golddove golddove requested a review from almedina-ms May 27, 2021 17:15
@golddove golddove enabled auto-merge (squash) May 27, 2021 23:09
@golddove golddove merged commit d7fd2d4 into main May 27, 2021
@golddove golddove deleted the golddove/5725 branch May 27, 2021 23:44
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
* 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
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Table Implementation
3 participants