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

Rename sentiment to style #2979

Merged
merged 11 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
"actions": [
{
"type": "Action.OpenUrl",
"sentiment": "default",
"style": "default",
"url": "http://adaptivecards.io",
"title": "Default"
},
{
"type": "Action.OpenUrl",
"sentiment": "positive",
"style": "positive",
"url": "http://adaptivecards.io",
"title": "Pawsitive"
},
{
"type": "Action.OpenUrl",
"sentiment": "destructive",
"style": "destructive",
"url": "http://adaptivecards.io",
"title": "Destructive"
},
{
"type": "Action.OpenUrl",
"sentiment": "other",
"style": "other",
"url": "http://adaptivecards.io",
"title": "Other"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
{
"type": "Action.ShowCard",
"sentiment": "positive",
"style": "positive",
"title": "Pawsitive",
"card": {
"type": "AdaptiveCard",
Expand All @@ -31,7 +31,7 @@
},
{
"type": "Action.ShowCard",
"sentiment": "destructive",
"style": "destructive",
"title": "Destructive",
"card": {
"type": "AdaptiveCard",
Expand All @@ -41,7 +41,7 @@
},
{
"type": "Action.ShowCard",
"sentiment": "other",
"style": "other",
"title": "Other",
"card": {
"type": "AdaptiveCard",
Expand All @@ -50,4 +50,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"actions": [
{
"type": "Action.Submit",
"sentiment": "default",
"style": "default",
"title": "Default"
},
{
"type": "Action.Submit",
"sentiment": "positive",
"style": "positive",
"title": "Pawsitive"
},
{
"type": "Action.Submit",
"sentiment": "destructive",
"style": "destructive",
"title": "Destructive"
},
{
"type": "Action.Submit",
"sentiment": "other",
"style": "other",
"title": "Other"
}
]
}
}
36 changes: 18 additions & 18 deletions source/android/adaptivecards/src/main/cpp/objectmodel_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,15 +2770,15 @@ void SwigDirector_BaseActionElement::SetIconUrl(std::string const &value) {
if (swigjobj) jenv->DeleteLocalRef(swigjobj);
}

std::string SwigDirector_BaseActionElement::GetSentiment() const {
std::string SwigDirector_BaseActionElement::GetStyle() const {
std::string c_result ;
jstring jresult = 0 ;
JNIEnvWrapper swigjnienv(this) ;
JNIEnv * jenv = swigjnienv.getJNIEnv() ;
jobject swigjobj = (jobject) NULL ;

if (!swig_override[10]) {
return AdaptiveCards::BaseActionElement::GetSentiment();
return AdaptiveCards::BaseActionElement::GetStyle();
}
swigjobj = swig_get_self(jenv);
if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {
Expand All @@ -2799,20 +2799,20 @@ std::string SwigDirector_BaseActionElement::GetSentiment() const {
c_result.assign(c_result_pstr);
jenv->ReleaseStringUTFChars(jresult, c_result_pstr);
} else {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object in AdaptiveCards::BaseActionElement::GetSentiment ");
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object in AdaptiveCards::BaseActionElement::GetStyle ");
}
if (swigjobj) jenv->DeleteLocalRef(swigjobj);
return c_result;
}

void SwigDirector_BaseActionElement::SetSentiment(std::string const &value) {
void SwigDirector_BaseActionElement::SetStyle(std::string const &value) {
JNIEnvWrapper swigjnienv(this) ;
JNIEnv * jenv = swigjnienv.getJNIEnv() ;
jobject swigjobj = (jobject) NULL ;
jstring jvalue = 0 ;

if (!swig_override[11]) {
AdaptiveCards::BaseActionElement::SetSentiment(value);
AdaptiveCards::BaseActionElement::SetStyle(value);
return;
}
swigjobj = swig_get_self(jenv);
Expand All @@ -2826,7 +2826,7 @@ void SwigDirector_BaseActionElement::SetSentiment(std::string const &value) {
}

} else {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object in AdaptiveCards::BaseActionElement::SetSentiment ");
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null upcall object in AdaptiveCards::BaseActionElement::SetStyle ");
}
if (swigjobj) jenv->DeleteLocalRef(swigjobj);
}
Expand Down Expand Up @@ -2894,10 +2894,10 @@ void SwigDirector_BaseActionElement::swig_connect_director(JNIEnv *jenv, jobject
"SetIconUrl", "(Ljava/lang/String;)V", NULL
},
{
"GetSentiment", "()Ljava/lang/String;", NULL
"GetStyle", "()Ljava/lang/String;", NULL
},
{
"SetSentiment", "(Ljava/lang/String;)V", NULL
"SetStyle", "(Ljava/lang/String;)V", NULL
},
{
"GetElementType", "()Lio/adaptivecards/objectmodel/ActionType;", NULL
Expand Down Expand Up @@ -10411,7 +10411,7 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
}


SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1GetSentiment(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1GetStyle(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jstring jresult = 0 ;
AdaptiveCards::BaseActionElement *arg1 = (AdaptiveCards::BaseActionElement *) 0 ;
std::shared_ptr< AdaptiveCards::BaseActionElement const > *smartarg1 = 0 ;
Expand All @@ -10423,13 +10423,13 @@ SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectM

smartarg1 = *(std::shared_ptr< const AdaptiveCards::BaseActionElement > **)&jarg1;
arg1 = (AdaptiveCards::BaseActionElement *)(smartarg1 ? smartarg1->get() : 0);
result = ((AdaptiveCards::BaseActionElement const *)arg1)->GetSentiment();
result = ((AdaptiveCards::BaseActionElement const *)arg1)->GetStyle();
jresult = jenv->NewStringUTF((&result)->c_str());
return jresult;
}


SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1GetSentimentSwigExplicitBaseActionElement(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1GetStyleSwigExplicitBaseActionElement(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jstring jresult = 0 ;
AdaptiveCards::BaseActionElement *arg1 = (AdaptiveCards::BaseActionElement *) 0 ;
std::shared_ptr< AdaptiveCards::BaseActionElement const > *smartarg1 = 0 ;
Expand All @@ -10441,13 +10441,13 @@ SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectM

smartarg1 = *(std::shared_ptr< const AdaptiveCards::BaseActionElement > **)&jarg1;
arg1 = (AdaptiveCards::BaseActionElement *)(smartarg1 ? smartarg1->get() : 0);
result = ((AdaptiveCards::BaseActionElement const *)arg1)->AdaptiveCards::BaseActionElement::GetSentiment();
result = ((AdaptiveCards::BaseActionElement const *)arg1)->AdaptiveCards::BaseActionElement::GetStyle();
jresult = jenv->NewStringUTF((&result)->c_str());
return jresult;
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1SetSentiment(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1SetStyle(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
AdaptiveCards::BaseActionElement *arg1 = (AdaptiveCards::BaseActionElement *) 0 ;
std::string *arg2 = 0 ;
std::shared_ptr< AdaptiveCards::BaseActionElement > *smartarg1 = 0 ;
Expand All @@ -10467,11 +10467,11 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
std::string arg2_str(arg2_pstr);
arg2 = &arg2_str;
jenv->ReleaseStringUTFChars(jarg2, arg2_pstr);
(arg1)->SetSentiment((std::string const &)*arg2);
(arg1)->SetStyle((std::string const &)*arg2);
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1SetSentimentSwigExplicitBaseActionElement(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseActionElement_1SetStyleSwigExplicitBaseActionElement(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
AdaptiveCards::BaseActionElement *arg1 = (AdaptiveCards::BaseActionElement *) 0 ;
std::string *arg2 = 0 ;
std::shared_ptr< AdaptiveCards::BaseActionElement > *smartarg1 = 0 ;
Expand All @@ -10491,7 +10491,7 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
std::string arg2_str(arg2_pstr);
arg2 = &arg2_str;
jenv->ReleaseStringUTFChars(jarg2, arg2_pstr);
(arg1)->AdaptiveCards::BaseActionElement::SetSentiment((std::string const &)*arg2);
(arg1)->AdaptiveCards::BaseActionElement::SetStyle((std::string const &)*arg2);
}


Expand Down Expand Up @@ -28679,10 +28679,10 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
"SwigDirector_BaseActionElement_SetIconUrl", "(Lio/adaptivecards/objectmodel/BaseActionElement;Ljava/lang/String;)V"
},
{
"SwigDirector_BaseActionElement_GetSentiment", "(Lio/adaptivecards/objectmodel/BaseActionElement;)Ljava/lang/String;"
"SwigDirector_BaseActionElement_GetStyle", "(Lio/adaptivecards/objectmodel/BaseActionElement;)Ljava/lang/String;"
},
{
"SwigDirector_BaseActionElement_SetSentiment", "(Lio/adaptivecards/objectmodel/BaseActionElement;Ljava/lang/String;)V"
"SwigDirector_BaseActionElement_SetStyle", "(Lio/adaptivecards/objectmodel/BaseActionElement;Ljava/lang/String;)V"
},
{
"SwigDirector_BaseActionElement_GetElementType", "(Lio/adaptivecards/objectmodel/BaseActionElement;)I"
Expand Down
4 changes: 2 additions & 2 deletions source/android/adaptivecards/src/main/cpp/objectmodel_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class SwigDirector_BaseActionElement : public AdaptiveCards::BaseActionElement,
virtual void SetTitle(std::string const &value);
virtual std::string GetIconUrl() const;
virtual void SetIconUrl(std::string const &value);
virtual std::string GetSentiment() const;
virtual void SetSentiment(std::string const &value);
virtual std::string GetStyle() const;
virtual void SetStyle(std::string const &value);
virtual AdaptiveCards::ActionType const GetElementType() const;
public:
bool swig_overrides(int n) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,10 @@ public class AdaptiveCardObjectModelJNI {
public final static native String BaseActionElement_GetIconUrlSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_);
public final static native void BaseActionElement_SetIconUrl(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native void BaseActionElement_SetIconUrlSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native String BaseActionElement_GetSentiment(long jarg1, BaseActionElement jarg1_);
public final static native String BaseActionElement_GetSentimentSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_);
public final static native void BaseActionElement_SetSentiment(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native void BaseActionElement_SetSentimentSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native String BaseActionElement_GetStyle(long jarg1, BaseActionElement jarg1_);
public final static native String BaseActionElement_GetStyleSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_);
public final static native void BaseActionElement_SetStyle(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native void BaseActionElement_SetStyleSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_, String jarg2);
public final static native int BaseActionElement_GetElementType(long jarg1, BaseActionElement jarg1_);
public final static native int BaseActionElement_GetElementTypeSwigExplicitBaseActionElement(long jarg1, BaseActionElement jarg1_);
public final static native void BaseActionElement_GetResourceInformation(long jarg1, BaseActionElement jarg1_, long jarg2, RemoteResourceInformationVector jarg2_);
Expand Down Expand Up @@ -1493,11 +1493,11 @@ public static String SwigDirector_BaseActionElement_GetIconUrl(BaseActionElement
public static void SwigDirector_BaseActionElement_SetIconUrl(BaseActionElement jself, String value) {
jself.SetIconUrl(value);
}
public static String SwigDirector_BaseActionElement_GetSentiment(BaseActionElement jself) {
return jself.GetSentiment();
public static String SwigDirector_BaseActionElement_GetStyle(BaseActionElement jself) {
return jself.GetStyle();
}
public static void SwigDirector_BaseActionElement_SetSentiment(BaseActionElement jself, String value) {
jself.SetSentiment(value);
public static void SwigDirector_BaseActionElement_SetStyle(BaseActionElement jself, String value) {
jself.SetStyle(value);
}
public static int SwigDirector_BaseActionElement_GetElementType(BaseActionElement jself) {
return (jself.GetElementType()).swigValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public enum AdaptiveCardSchemaKey {
RichTextBlock,
Right,
SelectAction,
Sentiment,
Separator,
ShowActionMode,
ShowCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ public void SetIconUrl(String value) {
if (getClass() == BaseActionElement.class) AdaptiveCardObjectModelJNI.BaseActionElement_SetIconUrl(swigCPtr, this, value); else AdaptiveCardObjectModelJNI.BaseActionElement_SetIconUrlSwigExplicitBaseActionElement(swigCPtr, this, value);
}

public String GetSentiment() {
return (getClass() == BaseActionElement.class) ? AdaptiveCardObjectModelJNI.BaseActionElement_GetSentiment(swigCPtr, this) : AdaptiveCardObjectModelJNI.BaseActionElement_GetSentimentSwigExplicitBaseActionElement(swigCPtr, this);
public String GetStyle() {
return (getClass() == BaseActionElement.class) ? AdaptiveCardObjectModelJNI.BaseActionElement_GetStyle(swigCPtr, this) : AdaptiveCardObjectModelJNI.BaseActionElement_GetStyleSwigExplicitBaseActionElement(swigCPtr, this);
}

public void SetSentiment(String value) {
if (getClass() == BaseActionElement.class) AdaptiveCardObjectModelJNI.BaseActionElement_SetSentiment(swigCPtr, this, value); else AdaptiveCardObjectModelJNI.BaseActionElement_SetSentimentSwigExplicitBaseActionElement(swigCPtr, this, value);
public void SetStyle(String value) {
if (getClass() == BaseActionElement.class) AdaptiveCardObjectModelJNI.BaseActionElement_SetStyle(swigCPtr, this, value); else AdaptiveCardObjectModelJNI.BaseActionElement_SetStyleSwigExplicitBaseActionElement(swigCPtr, this, value);
}

public ActionType GetElementType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ private static Button createButtonWithTheme(Context context, int theme)
return new Button(themedContext);
}

protected static Button getButtonForSentiment(Context context, String sentiment, HostConfig hostConfig)
protected static Button getButtonForStyle(Context context, String style, HostConfig hostConfig)
{
boolean isPositiveSentiment = sentiment.equalsIgnoreCase("Positive");
boolean isDestructiveSentiment = sentiment.equalsIgnoreCase("Destructive");
boolean isPositiveStyle = style.equalsIgnoreCase("Positive");
boolean isDestructiveStyle = style.equalsIgnoreCase("Destructive");

if(isPositiveSentiment || isDestructiveSentiment)
if(isPositiveStyle || isDestructiveStyle)
{
Resources.Theme theme = context.getTheme();
TypedValue buttonStyle = new TypedValue();

if(isPositiveSentiment)
if(isPositiveStyle)
{
if(theme.resolveAttribute(R.attr.adaptiveActionPositive, buttonStyle, true))
{
Expand Down Expand Up @@ -174,7 +174,7 @@ public Button renderButton(
RenderedAdaptiveCard renderedCard,
RenderArgs renderArgs)
{
Button button = getButtonForSentiment(context, baseActionElement.GetSentiment(), hostConfig);
Button button = getButtonForStyle(context, baseActionElement.GetStyle(), hostConfig);

button.setText(baseActionElement.GetTitle());
ActionAlignment alignment = hostConfig.GetActions().getActionAlignment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ protected static HtmlTag AdaptiveActionRender(AdaptiveAction action, AdaptiveRen
.AddClass("ac-pushButton");


if (!String.IsNullOrWhiteSpace(action.Sentiment) && !String.Equals(action.Sentiment, "default", StringComparison.OrdinalIgnoreCase))
if (!String.IsNullOrWhiteSpace(action.Style) && !String.Equals(action.Style, "default", StringComparison.OrdinalIgnoreCase))
{
if (String.Equals(action.Sentiment, "positive", StringComparison.OrdinalIgnoreCase))
if (String.Equals(action.Style, "positive", StringComparison.OrdinalIgnoreCase))
{
string accentColor = context.Config.ContainerStyles.Default.ForegroundColors.Accent.Default;
string lighterAccentColor = ColorUtil.GenerateLighterColor(accentColor);
Expand All @@ -202,7 +202,7 @@ protected static HtmlTag AdaptiveActionRender(AdaptiveAction action, AdaptiveRen
buttonElement.Style("color", "#FFFFFF");
buttonElement.AddClass("ac-action-positive");
}
else if (String.Equals(action.Sentiment, "destructive", StringComparison.OrdinalIgnoreCase))
else if (String.Equals(action.Style, "destructive", StringComparison.OrdinalIgnoreCase))
{
string attentionColor = context.Config.ContainerStyles.Default.ForegroundColors.Attention.Default;
string lighterAttentionColor = ColorUtil.GenerateLighterColor(attentionColor);
Expand All @@ -213,7 +213,7 @@ protected static HtmlTag AdaptiveActionRender(AdaptiveAction action, AdaptiveRen
}
else
{
buttonElement.AddClass("ac-action-" + action.Sentiment);
buttonElement.AddClass("ac-action-" + action.Style);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ public static Button CreateActionButton(AdaptiveAction action, AdaptiveRenderCon
Style = context.GetStyle($"Adaptive.{action.Type}"),
};

if (!String.IsNullOrWhiteSpace(action.Sentiment))
if (!String.IsNullOrWhiteSpace(action.Style))
{
Style sentimentStyle = context.GetStyle($"Adaptive.{action.Type}.{action.Sentiment}");
Style style = context.GetStyle($"Adaptive.{action.Type}.{action.Style}");

if (sentimentStyle == null && String.Equals(action.Sentiment, "positive", StringComparison.OrdinalIgnoreCase))
if (style == null && String.Equals(action.Style, "positive", StringComparison.OrdinalIgnoreCase))
{
sentimentStyle = context.GetStyle("PositiveActionDefaultStyle");
style = context.GetStyle("PositiveActionDefaultStyle");
}
else if (sentimentStyle == null && String.Equals(action.Sentiment, "destructive", StringComparison.OrdinalIgnoreCase))
else if (style == null && String.Equals(action.Style, "destructive", StringComparison.OrdinalIgnoreCase))
{
sentimentStyle = context.GetStyle("DestructiveActionDefaultStyle");
style = context.GetStyle("DestructiveActionDefaultStyle");
}

uiButton.Style = sentimentStyle;
uiButton.Style = style;
}

var contentStackPanel = new StackPanel();
Expand Down
Loading