Skip to content

Commit

Permalink
[Shared][Android] Background image spec updates (microsoft#2868)
Browse files Browse the repository at this point in the history
* Fix build errors

* Add swig generated files for android

* Add support for vertial and horizontal cover in Android

* Fix json payload

* Add missing test file

* Fix behaviour for background image rendering

* Jwoo/ios background image changes (microsoft#2920)

* fixes unit test on shared model

* dev complete

* [UWP] Renames from Background Image spec updates (microsoft#2928)
  • Loading branch information
almedina-ms committed May 17, 2019
1 parent cb18881 commit 60c74d2
Show file tree
Hide file tree
Showing 108 changed files with 650 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"width": "auto",
"backgroundImage": {
"url": "https://picsum.photos/id/237/200/200",
"horizontalAlignment": "left",
"horizontalAlignment": "left"
},
"items": [
{
Expand Down
57 changes: 57 additions & 0 deletions samples/v1.2/Elements/AdaptiveCard.BackgroundImage.FillMode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "http:https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"backgroundImage": {
"url": "https://picsum.photos/60/60?image=101",
"fillMode": "repeat"
},
"body": [
{
"type": "TextBlock",
"text": "Text in body"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"text": "Text in Column 1"
}
]
},
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"text": "Text in Column 2"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Text 1 in Container"
},
{
"type": "TextBlock",
"text": "Text 2 in Container"
},
{
"type": "TextBlock",
"text": "Text 3 in Container"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "http:https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"backgroundImage": {
"url": "https://picsum.photos/60/60?image=101",
"fillMode": "repeatHorizontally",
"verticalAlignment": "center"
},
"body": [
{
"type": "TextBlock",
"text": "Text in body"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"text": "Text in Column 1"
}
]
},
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"text": "Text in Column 2"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Text 1 in Container"
},
{
"type": "TextBlock",
"text": "Text 2 in Container"
},
{
"type": "TextBlock",
"text": "Text 3 in Container"
}
]
}
]
}
42 changes: 21 additions & 21 deletions source/android/adaptivecards/src/main/cpp/objectmodel_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8091,36 +8091,36 @@ SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_getBackgroundImageModeEnum(JNIEnv *jenv, jclass jcls) {
SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_getImageFillModeEnum(JNIEnv *jenv, jclass jcls) {
jlong jresult = 0 ;
AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::BackgroundImageMode > *result = 0 ;
AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::ImageFillMode > *result = 0 ;

(void)jenv;
(void)jcls;
result = (AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::BackgroundImageMode > *) &AdaptiveCards::EnumHelpers::getBackgroundImageModeEnum();
*(AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::BackgroundImageMode > **)&jresult = result;
result = (AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::ImageFillMode > *) &AdaptiveCards::EnumHelpers::getImageFillModeEnum();
*(AdaptiveCards::EnumHelpers::EnumMapping< AdaptiveCards::ImageFillMode > **)&jresult = result;
return jresult;
}


SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImageModeToString(JNIEnv *jenv, jclass jcls, jint jarg1) {
SWIGEXPORT jstring JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_ImageFillModeToString(JNIEnv *jenv, jclass jcls, jint jarg1) {
jstring jresult = 0 ;
AdaptiveCards::BackgroundImageMode arg1 ;
AdaptiveCards::ImageFillMode arg1 ;
std::string result;

(void)jenv;
(void)jcls;
arg1 = (AdaptiveCards::BackgroundImageMode)jarg1;
result = AdaptiveCards::BackgroundImageModeToString(arg1);
arg1 = (AdaptiveCards::ImageFillMode)jarg1;
result = AdaptiveCards::ImageFillModeToString(arg1);
jresult = jenv->NewStringUTF((&result)->c_str());
return jresult;
}


SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImageModeFromString(JNIEnv *jenv, jclass jcls, jstring jarg1) {
SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_ImageFillModeFromString(JNIEnv *jenv, jclass jcls, jstring jarg1) {
jint jresult = 0 ;
std::string *arg1 = 0 ;
AdaptiveCards::BackgroundImageMode result;
AdaptiveCards::ImageFillMode result;

(void)jenv;
(void)jcls;
Expand All @@ -8133,7 +8133,7 @@ SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
std::string arg1_str(arg1_pstr);
arg1 = &arg1_str;
jenv->ReleaseStringUTFChars(jarg1, arg1_pstr);
result = (AdaptiveCards::BackgroundImageMode)AdaptiveCards::BackgroundImageModeFromString((std::string const &)*arg1);
result = (AdaptiveCards::ImageFillMode)AdaptiveCards::ImageFillModeFromString((std::string const &)*arg1);
jresult = (jint)result;
return jresult;
}
Expand Down Expand Up @@ -10778,7 +10778,7 @@ SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMod
SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_new_1BackgroundImage_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jint jarg3, jint jarg4) {
jlong jresult = 0 ;
std::string *arg1 = 0 ;
AdaptiveCards::BackgroundImageMode arg2 ;
AdaptiveCards::ImageFillMode arg2 ;
AdaptiveCards::HorizontalAlignment arg3 ;
AdaptiveCards::VerticalAlignment arg4 ;
AdaptiveCards::BackgroundImage *result = 0 ;
Expand All @@ -10794,7 +10794,7 @@ SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMod
std::string arg1_str(arg1_pstr);
arg1 = &arg1_str;
jenv->ReleaseStringUTFChars(jarg1, arg1_pstr);
arg2 = (AdaptiveCards::BackgroundImageMode)jarg2;
arg2 = (AdaptiveCards::ImageFillMode)jarg2;
arg3 = (AdaptiveCards::HorizontalAlignment)jarg3;
arg4 = (AdaptiveCards::VerticalAlignment)jarg4;
result = (AdaptiveCards::BackgroundImage *)new AdaptiveCards::BackgroundImage((std::string const &)*arg1,arg2,arg3,arg4);
Expand Down Expand Up @@ -10847,39 +10847,39 @@ SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMode
}


SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImage_1GetMode(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
SWIGEXPORT jint JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImage_1GetFillMode(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jint jresult = 0 ;
AdaptiveCards::BackgroundImage *arg1 = (AdaptiveCards::BackgroundImage *) 0 ;
std::shared_ptr< AdaptiveCards::BackgroundImage const > *smartarg1 = 0 ;
AdaptiveCards::BackgroundImageMode result;
AdaptiveCards::ImageFillMode result;

(void)jenv;
(void)jcls;
(void)jarg1_;

smartarg1 = *(std::shared_ptr< const AdaptiveCards::BackgroundImage > **)&jarg1;
arg1 = (AdaptiveCards::BackgroundImage *)(smartarg1 ? smartarg1->get() : 0);
result = (AdaptiveCards::BackgroundImageMode)((AdaptiveCards::BackgroundImage const *)arg1)->GetMode();
result = (AdaptiveCards::ImageFillMode)((AdaptiveCards::BackgroundImage const *)arg1)->GetFillMode();
jresult = (jint)result;
return jresult;
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImage_1SetMode(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BackgroundImage_1SetFillMode(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
AdaptiveCards::BackgroundImage *arg1 = (AdaptiveCards::BackgroundImage *) 0 ;
AdaptiveCards::BackgroundImageMode *arg2 = 0 ;
AdaptiveCards::ImageFillMode *arg2 = 0 ;
std::shared_ptr< AdaptiveCards::BackgroundImage > *smartarg1 = 0 ;
AdaptiveCards::BackgroundImageMode temp2 ;
AdaptiveCards::ImageFillMode temp2 ;

(void)jenv;
(void)jcls;
(void)jarg1_;

smartarg1 = *(std::shared_ptr< AdaptiveCards::BackgroundImage > **)&jarg1;
arg1 = (AdaptiveCards::BackgroundImage *)(smartarg1 ? smartarg1->get() : 0);
temp2 = (AdaptiveCards::BackgroundImageMode)jarg2;
temp2 = (AdaptiveCards::ImageFillMode)jarg2;
arg2 = &temp2;
(arg1)->SetMode((AdaptiveCards::BackgroundImageMode const &)*arg2);
(arg1)->SetFillMode((AdaptiveCards::ImageFillMode const &)*arg2);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ public static VerticalAlignment VerticalAlignmentFromString(String t) {
return VerticalAlignment.swigToEnum(AdaptiveCardObjectModelJNI.VerticalAlignmentFromString(t));
}

public static SWIGTYPE_p_AdaptiveCards__EnumHelpers__EnumMappingT_AdaptiveCards__BackgroundImageMode_t getBackgroundImageModeEnum() {
return new SWIGTYPE_p_AdaptiveCards__EnumHelpers__EnumMappingT_AdaptiveCards__BackgroundImageMode_t(AdaptiveCardObjectModelJNI.getBackgroundImageModeEnum(), false);
public static SWIGTYPE_p_AdaptiveCards__EnumHelpers__EnumMappingT_AdaptiveCards__ImageFillMode_t getImageFillModeEnum() {
return new SWIGTYPE_p_AdaptiveCards__EnumHelpers__EnumMappingT_AdaptiveCards__ImageFillMode_t(AdaptiveCardObjectModelJNI.getImageFillModeEnum(), false);
}

public static String BackgroundImageModeToString(BackgroundImageMode t) {
return AdaptiveCardObjectModelJNI.BackgroundImageModeToString(t.swigValue());
public static String ImageFillModeToString(ImageFillMode t) {
return AdaptiveCardObjectModelJNI.ImageFillModeToString(t.swigValue());
}

public static BackgroundImageMode BackgroundImageModeFromString(String t) {
return BackgroundImageMode.swigToEnum(AdaptiveCardObjectModelJNI.BackgroundImageModeFromString(t));
public static ImageFillMode ImageFillModeFromString(String t) {
return ImageFillMode.swigToEnum(AdaptiveCardObjectModelJNI.ImageFillModeFromString(t));
}

public static SWIGTYPE_p_AdaptiveCards__EnumHelpers__EnumMappingT_AdaptiveCards__ImageStyle_t getImageStyleEnum() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ public class AdaptiveCardObjectModelJNI {
public final static native long getVerticalAlignmentEnum();
public final static native String VerticalAlignmentToString(int jarg1);
public final static native int VerticalAlignmentFromString(String jarg1);
public final static native long getBackgroundImageModeEnum();
public final static native String BackgroundImageModeToString(int jarg1);
public final static native int BackgroundImageModeFromString(String jarg1);
public final static native long getImageFillModeEnum();
public final static native String ImageFillModeToString(int jarg1);
public final static native int ImageFillModeFromString(String jarg1);
public final static native long getImageStyleEnum();
public final static native String ImageStyleToString(int jarg1);
public final static native int ImageStyleFromString(String jarg1);
Expand Down Expand Up @@ -458,8 +458,8 @@ public class AdaptiveCardObjectModelJNI {
public final static native long new_BackgroundImage__SWIG_2(String jarg1, int jarg2, int jarg3, int jarg4);
public final static native String BackgroundImage_GetUrl(long jarg1, BackgroundImage jarg1_);
public final static native void BackgroundImage_SetUrl(long jarg1, BackgroundImage jarg1_, String jarg2);
public final static native int BackgroundImage_GetMode(long jarg1, BackgroundImage jarg1_);
public final static native void BackgroundImage_SetMode(long jarg1, BackgroundImage jarg1_, int jarg2);
public final static native int BackgroundImage_GetFillMode(long jarg1, BackgroundImage jarg1_);
public final static native void BackgroundImage_SetFillMode(long jarg1, BackgroundImage jarg1_, int jarg2);
public final static native int BackgroundImage_GetHorizontalAlignment(long jarg1, BackgroundImage jarg1_);
public final static native void BackgroundImage_SetHorizontalAlignment(long jarg1, BackgroundImage jarg1_, int jarg2);
public final static native int BackgroundImage_GetVerticalAlignment(long jarg1, BackgroundImage jarg1_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public enum AdaptiveCardSchemaKey {
Facts,
Fallback,
FallbackText,
FillMode,
FontFamily,
FontSizes,
FontStyle,
Expand Down Expand Up @@ -110,7 +111,6 @@ public enum AdaptiveCardSchemaKey {
MimeType,
Min,
MinHeight,
Mode,
Monospace,
NumberInput,
Padding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public BackgroundImage(String url) {
this(AdaptiveCardObjectModelJNI.new_BackgroundImage__SWIG_1(url), true);
}

public BackgroundImage(String url, BackgroundImageMode mode, HorizontalAlignment hAlignment, VerticalAlignment vAlignment) {
this(AdaptiveCardObjectModelJNI.new_BackgroundImage__SWIG_2(url, mode.swigValue(), hAlignment.swigValue(), vAlignment.swigValue()), true);
public BackgroundImage(String url, ImageFillMode fillMode, HorizontalAlignment hAlignment, VerticalAlignment vAlignment) {
this(AdaptiveCardObjectModelJNI.new_BackgroundImage__SWIG_2(url, fillMode.swigValue(), hAlignment.swigValue(), vAlignment.swigValue()), true);
}

public String GetUrl() {
Expand All @@ -59,12 +59,12 @@ public void SetUrl(String value) {
AdaptiveCardObjectModelJNI.BackgroundImage_SetUrl(swigCPtr, this, value);
}

public BackgroundImageMode GetMode() {
return BackgroundImageMode.swigToEnum(AdaptiveCardObjectModelJNI.BackgroundImage_GetMode(swigCPtr, this));
public ImageFillMode GetFillMode() {
return ImageFillMode.swigToEnum(AdaptiveCardObjectModelJNI.BackgroundImage_GetFillMode(swigCPtr, this));
}

public void SetMode(BackgroundImageMode value) {
AdaptiveCardObjectModelJNI.BackgroundImage_SetMode(swigCPtr, this, value.swigValue());
public void SetFillMode(ImageFillMode value) {
AdaptiveCardObjectModelJNI.BackgroundImage_SetFillMode(swigCPtr, this, value.swigValue());
}

public HorizontalAlignment GetHorizontalAlignment() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http:https://www.swig.org).
* Version 4.0.0
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package io.adaptivecards.objectmodel;

public enum ImageFillMode {
Cover(0),
RepeatHorizontally,
RepeatVertically,
Repeat;

public final int swigValue() {
return swigValue;
}

public static ImageFillMode swigToEnum(int swigValue) {
ImageFillMode[] swigValues = ImageFillMode.class.getEnumConstants();
if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
return swigValues[swigValue];
for (ImageFillMode swigEnum : swigValues)
if (swigEnum.swigValue == swigValue)
return swigEnum;
throw new IllegalArgumentException("No enum " + ImageFillMode.class + " with value " + swigValue);
}

@SuppressWarnings("unused")
private ImageFillMode() {
this.swigValue = SwigNext.next++;
}

@SuppressWarnings("unused")
private ImageFillMode(int swigValue) {
this.swigValue = swigValue;
SwigNext.next = swigValue+1;
}

@SuppressWarnings("unused")
private ImageFillMode(ImageFillMode swigEnum) {
this.swigValue = swigEnum.swigValue;
SwigNext.next = this.swigValue+1;
}

private final int swigValue;

private static class SwigNext {
private static int next = 0;
}
}

Loading

0 comments on commit 60c74d2

Please sign in to comment.