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] Adding support for RatingInput and readOnly Rating Element #144

Merged
merged 18 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
200ca69
Merge branch 'main' of https://github.com/microsoft/AdaptiveCards-Mobile
singhmanp0707 May 17, 2024
473b954
Merge branch 'abhipandey/rating_element' of https://github.com/micros…
singhmanp0707 May 17, 2024
15a9c79
swig changes
singhmanp0707 May 20, 2024
027f375
Revert "swig changes"
singhmanp0707 May 20, 2024
970f024
Merge branch 'abhipandey/rating_element' of https://github.com/micros…
singhmanp0707 May 22, 2024
d99e21f
Merge branch 'abhipandey/rating_element' of https://github.com/micros…
singhmanp0707 May 22, 2024
86e7129
Merge branch 'abhipandey/rating_element' of https://github.com/micros…
singhmanp0707 May 23, 2024
e922852
implementation of rating element
singhmanp0707 May 23, 2024
957a65b
support count for default style for read only rating element
singhmanp0707 May 23, 2024
95040cf
revert gradle.properties version change
singhmanp0707 May 23, 2024
e394cb6
set state to activated for read only stars
singhmanp0707 May 23, 2024
b95fdb7
Merge branch 'abhipandey/rating_element' of https://github.com/micros…
singhmanp0707 May 27, 2024
0a43a20
Merge branch 'main' of https://github.com/microsoft/AdaptiveCards-Mob…
singhmanp0707 May 30, 2024
3c64c59
addressed review comments
singhmanp0707 May 30, 2024
9ee53af
added default case in switch statement
singhmanp0707 May 31, 2024
926774b
addressed review comments
singhmanp0707 May 31, 2024
24f120b
addressed review comments
singhmanp0707 Jun 3, 2024
7009428
Merge branch 'main' of https://github.com/microsoft/AdaptiveCards-Mob…
singhmanp0707 Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions samples/HostConfig/microsoft-teams-dark.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,33 @@
"warp": true
},
"spacing": 16
}
}
},
"ratingInput": {
"filledStar": {
"marigoldColor": "#F2C661",
"neutralColor": "#E1E1E1"
},

"emptyStar": {
"marigoldColor": "#F2C661",
"neutralColor": "#E1E1E1"
},

"ratingTextColor": "#000000",
"countTextColor": "#000000"
},
"ratingLabel": {
"filledStar": {
"marigoldColor": "#EAA300",
"neutralColor": "#E1E1E1"
},

"emptyStar": {
"marigoldColor": "#835B00",
"neutralColor": "#404040"
},

"ratingTextColor": "#E1E1E1",
"countTextColor": "#E1E1E1"
}
}
32 changes: 30 additions & 2 deletions samples/HostConfig/microsoft-teams-light.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,33 @@
"warp": true
},
"spacing": 16
}
}
},
"ratingInput": {
"filledStar": {
"marigoldColor": "#EAA300",
"neutralColor": "#212121"
},

"emptyStar": {
"marigoldColor": "#EAA300",
"neutralColor": "#212121"
},

"ratingTextColor": "#000000",
"countTextColor": "#000000"
},
"ratingLabel": {
"filledStar": {
"marigoldColor": "#EAA300",
"neutralColor": "#242424"
},

"emptyStar": {
"marigoldColor": "#F9E2AE",
"neutralColor": "#E1E1E1"
},

"ratingTextColor": "#000000",
"countTextColor": "#000000"
}
}
62 changes: 62 additions & 0 deletions samples/v1.5/Elements/Input.Rating.Actions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"type": "AdaptiveCard",
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"size": "Large",
"text": "Rating input"
},
{
"type": "Input.Rating",
"id": "rating1",
"label": "Pick a rating",
"size": "medium",
"isRequired": true,
"errorMessage": "Please pick a rating"
},
{
"type": "Input.Rating",
"id": "rating2",
"label": "Pick a rating",
"allowHalfSteps": true,
"size": "large",
"isRequired": true,
"errorMessage": "Please pick a rating",
"color": "marigold",
"value": 3
},
{
"type": "TextBlock",
"size": "large",
"text": "Read-only ratings",
"separator": true,
"spacing": "extraLarge"
},
{
"type": "Rating",
"value": 3.2,
"size": "medium"
},
{
"type": "Rating",
"max": 20,
"value": 3.2,
"color": "marigold"
},
{
"type": "Rating",
"style": "compact",
"value": 3.2,
"color": "marigold",
"count": 150
}
],
"actions": [
{
"type": "Action.Execute",
"title": "Submit"
}
]
}
72 changes: 72 additions & 0 deletions samples/v1.5/Scenarios/RatingInput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"type": "AdaptiveCard",
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"size": "Large",
"text": "Rating input"
},
{
"type": "Input.Rating",
"id": "rating1",
"size": "medium",
"isRequired": true,
"label": "Pick a rating",
"errorMessage": "Please pick a rating",
"horizontalAlignment": "left",
"max": 5
},
{
"type": "Input.Rating",
"id": "rating2",
"label": "Pick a rating",
"size": "large",
"isRequired": true,
"errorMessage": "Please pick a rating",
"color": "marigold",
"value": 2,
"horizontalAlignment": "left",
"max": 5
},
{
"type": "TextBlock",
"size": "large",
"text": "Read-only ratings",
"separator": true,
"spacing": "extraLarge"
},
{
"type": "Rating",
"value": 3.2,
"size": "medium",
"horizontalAlignment": "left",
"count": 10
},
{
"type": "Rating",
"max": 20,
"value": 3.2,
"color": "marigold",
"size": "large",
"horizontalAlignment": "left",
"count": 150
},
{
"type": "Rating",
"style": "compact",
"value": 3.2,
"color": "marigold",
"count": 1500,
"size": "large",
"horizontalAlignment": "left"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
]
}
2 changes: 2 additions & 0 deletions source/android/adaptivecards/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ add_library( # Sets the name of the library.
../../shared/cpp/ObjectModel/Refresh.cpp
../../shared/cpp/ObjectModel/RichTextBlock.cpp
../../shared/cpp/ObjectModel/RichTextElementProperties.cpp
../../shared/cpp/ObjectModel/RatingInput.cpp
../../shared/cpp/ObjectModel/RatingLabel.cpp
../../shared/cpp/ObjectModel/SemanticVersion.cpp
../../shared/cpp/ObjectModel/SharedAdaptiveCard.cpp
../../shared/cpp/ObjectModel/ShowCardAction.cpp
Expand Down
40 changes: 40 additions & 0 deletions source/android/adaptivecards/src/AdaptiveCardObjectModel.i
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
#include "../../../shared/cpp/ObjectModel/BackgroundImage.h"
#include "../../../shared/cpp/ObjectModel/Container.h"
#include "../../../shared/cpp/ObjectModel/Icon.h"
#include "../../../shared/cpp/ObjectModel/RatingLabel.h"
#include "../../../shared/cpp/ObjectModel/Image.h"
#include "../../../shared/cpp/ObjectModel/ImageSet.h"
#include "../../../shared/cpp/ObjectModel/InternalId.h"
Expand All @@ -132,6 +133,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
#include "../../../shared/cpp/ObjectModel/DateInput.h"
#include "../../../shared/cpp/ObjectModel/NumberInput.h"
#include "../../../shared/cpp/ObjectModel/TextInput.h"
#include "../../../shared/cpp/ObjectModel/RatingInput.h"
#include "../../../shared/cpp/ObjectModel/TimeInput.h"
#include "../../../shared/cpp/ObjectModel/ToggleInput.h"
#include "../../../shared/cpp/ObjectModel/OpenUrlAction.h"
Expand Down Expand Up @@ -195,6 +197,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
%shared_ptr(AdaptiveCards::Container)
%shared_ptr(AdaptiveCards::TextBlock)
%shared_ptr(AdaptiveCards::Icon)
%shared_ptr(AdaptiveCards::RatingLabel)
%shared_ptr(AdaptiveCards::Image)
%shared_ptr(AdaptiveCards::ImageSet)
%shared_ptr(AdaptiveCards::Column)
Expand All @@ -207,6 +210,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
%shared_ptr(AdaptiveCards::DateInput)
%shared_ptr(AdaptiveCards::NumberInput)
%shared_ptr(AdaptiveCards::TextInput)
%shared_ptr(AdaptiveCards::RatingInput)
%shared_ptr(AdaptiveCards::TimeInput)
%shared_ptr(AdaptiveCards::ToggleInput)
%shared_ptr(AdaptiveCards::ExecuteAction)
Expand All @@ -219,6 +223,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
%shared_ptr(AdaptiveCards::ContainerParser)
%shared_ptr(AdaptiveCards::TextBlockParser)
%shared_ptr(AdaptiveCards::IconParser)
%shared_ptr(AdaptiveCards::RatingLabelParser)
%shared_ptr(AdaptiveCards::ImageParser)
%shared_ptr(AdaptiveCards::ColumnParser)
%shared_ptr(AdaptiveCards::ColumnSetParser)
Expand All @@ -229,6 +234,7 @@ STD_OPTIONAL(AdaptiveCards::VerticalContentAlignment, StdOptionalVerticalContent
%shared_ptr(AdaptiveCards::TableCellParser)
%shared_ptr(AdaptiveCards::TableRowParser)
%shared_ptr(AdaptiveCards::TextInputParser)
%shared_ptr(AdaptiveCards::RatingInputParser)
%shared_ptr(AdaptiveCards::TimeInputParser)
%shared_ptr(AdaptiveCards::ToggleInputParser)
%shared_ptr(AdaptiveCards::ExecuteActionParser)
Expand Down Expand Up @@ -473,6 +479,8 @@ namespace Json {
%template(AdaptiveCardParseWarningVector) std::vector<std::shared_ptr<AdaptiveCards::AdaptiveCardParseWarning> >;
%template(BaseCardElementVector) std::vector<std::shared_ptr<AdaptiveCards::BaseCardElement> >;
%template(IconVector) std::vector<std::shared_ptr<AdaptiveCards::Icon> >;
%template(RatingInputVector) std::vector<std::shared_ptr<AdaptiveCards::RatingInput> >;
%template(RatingLabelVector) std::vector<std::shared_ptr<AdaptiveCards::RatingLabel> >;
%template(ImageVector) std::vector<std::shared_ptr<AdaptiveCards::Image> >;
%template(FactVector) std::vector<std::shared_ptr<AdaptiveCards::Fact> >;
%template(ColumnVector) std::vector<std::shared_ptr<AdaptiveCards::Column> >;
Expand Down Expand Up @@ -582,6 +590,21 @@ namespace Json {
}
};

%exception AdaptiveCards::RatingLabel::dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
$action
if (!result) {
jclass excep = jenv->FindClass("java/lang/ClassCastException");
if (excep) {
jenv->ThrowNew(excep, "dynamic_cast exception");
}
}
}
%extend AdaptiveCards::RatingLabel {
static AdaptiveCards::RatingLabel *dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
return dynamic_cast<AdaptiveCards::RatingLabel *>(baseCardElement);
}
};

%exception AdaptiveCards::Image::dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
$action
if (!result) {
Expand Down Expand Up @@ -747,6 +770,21 @@ namespace Json {
}
};

%exception AdaptiveCards::RatingInput::dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
$action
if (!result) {
jclass excep = jenv->FindClass("java/lang/ClassCastException");
if (excep) {
jenv->ThrowNew(excep, "dynamic_cast exception");
}
}
}
%extend AdaptiveCards::RatingInput {
static AdaptiveCards::RatingInput *dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
return dynamic_cast<AdaptiveCards::RatingInput *>(baseCardElement);
}
};

%exception AdaptiveCards::TimeInput::dynamic_cast(AdaptiveCards::BaseCardElement *baseCardElement) {
$action
if (!result) {
Expand Down Expand Up @@ -935,6 +973,7 @@ namespace Json {
%include "../../../shared/cpp/ObjectModel/SemanticVersion.h"
%include "../../../shared/cpp/ObjectModel/Container.h"
%include "../../../shared/cpp/ObjectModel/Icon.h"
%include "../../../shared/cpp/ObjectModel/RatingLabel.h"
%include "../../../shared/cpp/ObjectModel/Image.h"
%include "../../../shared/cpp/ObjectModel/ImageSet.h"
%include "../../../shared/cpp/ObjectModel/Column.h"
Expand All @@ -945,6 +984,7 @@ namespace Json {
%include "../../../shared/cpp/ObjectModel/DateInput.h"
%include "../../../shared/cpp/ObjectModel/NumberInput.h"
%include "../../../shared/cpp/ObjectModel/TextInput.h"
%include "../../../shared/cpp/ObjectModel/RatingInput.h"
%include "../../../shared/cpp/ObjectModel/TimeInput.h"
%include "../../../shared/cpp/ObjectModel/ToggleInput.h"
%include "../../../shared/cpp/ObjectModel/ExecuteAction.h"
Expand Down
Loading