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] Add RichTextBlocks support #2546

Merged
merged 8 commits into from
Mar 18, 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
17 changes: 17 additions & 0 deletions source/android/adaptivecards/src/AdaptiveCardObjectModel.i
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ namespace Json {
%template(ToggleVisibilityTargetVector) std::vector<std::shared_ptr<AdaptiveCards::ToggleVisibilityTarget> >;
%template(StringVector) std::vector<std::string>;
%template(CharVector) std::vector<char>;
%template(InlineVector) std::vector<std::shared_ptr<AdaptiveCards::Inline>>;
%template(ParagraphVector) std::vector<std::shared_ptr<AdaptiveCards::Paragraph>>;

%template(EnableSharedFromThisContainer) std::enable_shared_from_this<AdaptiveCards::Container>;

Expand Down Expand Up @@ -659,6 +661,21 @@ namespace Json {
}
};

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

%include "../../../shared/cpp/ObjectModel/pch.h"
%include "../../../shared/cpp/ObjectModel/EnumMagic.h"
%include "../../../shared/cpp/ObjectModel/Enums.h"
Expand Down
1,110 changes: 937 additions & 173 deletions source/android/adaptivecards/src/main/cpp/objectmodel_wrap.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,38 @@ public class AdaptiveCardObjectModelJNI {
public final static native char CharVector_doSet(long jarg1, CharVector jarg1_, int jarg2, char jarg3);
public final static native void CharVector_doRemoveRange(long jarg1, CharVector jarg1_, int jarg2, int jarg3);
public final static native void delete_CharVector(long jarg1);
public final static native long new_InlineVector__SWIG_0();
public final static native long new_InlineVector__SWIG_1(long jarg1, InlineVector jarg1_);
public final static native long InlineVector_capacity(long jarg1, InlineVector jarg1_);
public final static native void InlineVector_reserve(long jarg1, InlineVector jarg1_, long jarg2);
public final static native boolean InlineVector_isEmpty(long jarg1, InlineVector jarg1_);
public final static native void InlineVector_clear(long jarg1, InlineVector jarg1_);
public final static native long new_InlineVector__SWIG_2(int jarg1);
public final static native long new_InlineVector__SWIG_3(int jarg1, long jarg2, Inline jarg2_);
public final static native int InlineVector_doSize(long jarg1, InlineVector jarg1_);
public final static native void InlineVector_doAdd__SWIG_0(long jarg1, InlineVector jarg1_, long jarg2, Inline jarg2_);
public final static native void InlineVector_doAdd__SWIG_1(long jarg1, InlineVector jarg1_, int jarg2, long jarg3, Inline jarg3_);
public final static native long InlineVector_doRemove(long jarg1, InlineVector jarg1_, int jarg2);
public final static native long InlineVector_doGet(long jarg1, InlineVector jarg1_, int jarg2);
public final static native long InlineVector_doSet(long jarg1, InlineVector jarg1_, int jarg2, long jarg3, Inline jarg3_);
public final static native void InlineVector_doRemoveRange(long jarg1, InlineVector jarg1_, int jarg2, int jarg3);
public final static native void delete_InlineVector(long jarg1);
public final static native long new_ParagraphVector__SWIG_0();
public final static native long new_ParagraphVector__SWIG_1(long jarg1, ParagraphVector jarg1_);
public final static native long ParagraphVector_capacity(long jarg1, ParagraphVector jarg1_);
public final static native void ParagraphVector_reserve(long jarg1, ParagraphVector jarg1_, long jarg2);
public final static native boolean ParagraphVector_isEmpty(long jarg1, ParagraphVector jarg1_);
public final static native void ParagraphVector_clear(long jarg1, ParagraphVector jarg1_);
public final static native long new_ParagraphVector__SWIG_2(int jarg1);
public final static native long new_ParagraphVector__SWIG_3(int jarg1, long jarg2, Paragraph jarg2_);
public final static native int ParagraphVector_doSize(long jarg1, ParagraphVector jarg1_);
public final static native void ParagraphVector_doAdd__SWIG_0(long jarg1, ParagraphVector jarg1_, long jarg2, Paragraph jarg2_);
public final static native void ParagraphVector_doAdd__SWIG_1(long jarg1, ParagraphVector jarg1_, int jarg2, long jarg3, Paragraph jarg3_);
public final static native long ParagraphVector_doRemove(long jarg1, ParagraphVector jarg1_, int jarg2);
public final static native long ParagraphVector_doGet(long jarg1, ParagraphVector jarg1_, int jarg2);
public final static native long ParagraphVector_doSet(long jarg1, ParagraphVector jarg1_, int jarg2, long jarg3, Paragraph jarg3_);
public final static native void ParagraphVector_doRemoveRange(long jarg1, ParagraphVector jarg1_, int jarg2, int jarg3);
public final static native void delete_ParagraphVector(long jarg1);
public final static native long EnableSharedFromThisContainer_shared_from_this(long jarg1, EnableSharedFromThisContainer jarg1_);
public final static native long new_CaseInsensitiveEqualTo();
public final static native void delete_CaseInsensitiveEqualTo(long jarg1);
Expand Down Expand Up @@ -1281,6 +1313,9 @@ public class AdaptiveCardObjectModelJNI {
public final static native void TextRun_SetIsSubtle(long jarg1, TextRun jarg1_, boolean jarg2);
public final static native void TextRun_SetLanguage(long jarg1, TextRun jarg1_, String jarg2);
public final static native String TextRun_GetLanguage(long jarg1, TextRun jarg1_);
public final static native long TextRun_GetSelectAction(long jarg1, TextRun jarg1_);
public final static native void TextRun_SetSelectAction(long jarg1, TextRun jarg1_, long jarg2, BaseActionElement jarg2_);
public final static native long TextRun_dynamic_cast(long jarg1, Inline jarg1_);
public final static native long BaseCardElement_SWIGSmartPtrUpcast(long jarg1);
public final static native long BaseActionElement_SWIGSmartPtrUpcast(long jarg1);
public final static native long BaseInputElement_SWIGSmartPtrUpcast(long jarg1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://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 class InlineVector extends java.util.AbstractList<Inline> implements java.util.RandomAccess {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;

protected InlineVector(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(InlineVector obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
AdaptiveCardObjectModelJNI.delete_InlineVector(swigCPtr);
}
swigCPtr = 0;
}
}

public InlineVector(Inline[] initialElements) {
this();
for (Inline element : initialElements) {
add(element);
}
}

public InlineVector(Iterable<Inline> initialElements) {
this();
for (Inline element : initialElements) {
add(element);
}
}

public Inline get(int index) {
return doGet(index);
}

public Inline set(int index, Inline e) {
return doSet(index, e);
}

public boolean add(Inline e) {
modCount++;
doAdd(e);
return true;
}

public void add(int index, Inline e) {
modCount++;
doAdd(index, e);
}

public Inline remove(int index) {
modCount++;
return doRemove(index);
}

protected void removeRange(int fromIndex, int toIndex) {
modCount++;
doRemoveRange(fromIndex, toIndex);
}

public int size() {
return doSize();
}

public InlineVector() {
this(AdaptiveCardObjectModelJNI.new_InlineVector__SWIG_0(), true);
}

public InlineVector(InlineVector other) {
this(AdaptiveCardObjectModelJNI.new_InlineVector__SWIG_1(InlineVector.getCPtr(other), other), true);
}

public long capacity() {
return AdaptiveCardObjectModelJNI.InlineVector_capacity(swigCPtr, this);
}

public void reserve(long n) {
AdaptiveCardObjectModelJNI.InlineVector_reserve(swigCPtr, this, n);
}

public boolean isEmpty() {
return AdaptiveCardObjectModelJNI.InlineVector_isEmpty(swigCPtr, this);
}

public void clear() {
AdaptiveCardObjectModelJNI.InlineVector_clear(swigCPtr, this);
}

public InlineVector(int count) {
this(AdaptiveCardObjectModelJNI.new_InlineVector__SWIG_2(count), true);
}

public InlineVector(int count, Inline value) {
this(AdaptiveCardObjectModelJNI.new_InlineVector__SWIG_3(count, Inline.getCPtr(value), value), true);
}

private int doSize() {
return AdaptiveCardObjectModelJNI.InlineVector_doSize(swigCPtr, this);
}

private void doAdd(Inline value) {
AdaptiveCardObjectModelJNI.InlineVector_doAdd__SWIG_0(swigCPtr, this, Inline.getCPtr(value), value);
}

private void doAdd(int index, Inline value) {
AdaptiveCardObjectModelJNI.InlineVector_doAdd__SWIG_1(swigCPtr, this, index, Inline.getCPtr(value), value);
}

private Inline doRemove(int index) {
long cPtr = AdaptiveCardObjectModelJNI.InlineVector_doRemove(swigCPtr, this, index);
return (cPtr == 0) ? null : new Inline(cPtr, true);
}

private Inline doGet(int index) {
long cPtr = AdaptiveCardObjectModelJNI.InlineVector_doGet(swigCPtr, this, index);
return (cPtr == 0) ? null : new Inline(cPtr, true);
}

private Inline doSet(int index, Inline value) {
long cPtr = AdaptiveCardObjectModelJNI.InlineVector_doSet(swigCPtr, this, index, Inline.getCPtr(value), value);
return (cPtr == 0) ? null : new Inline(cPtr, true);
}

private void doRemoveRange(int fromIndex, int toIndex) {
AdaptiveCardObjectModelJNI.InlineVector_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public JsonValue SerializeToJsonValue() {
return new JsonValue(AdaptiveCardObjectModelJNI.Paragraph_SerializeToJsonValue(swigCPtr, this), true);
}

public SWIGTYPE_p_std__vectorT_std__shared_ptrT_AdaptiveCards__Inline_t_t GetInlines() {
return new SWIGTYPE_p_std__vectorT_std__shared_ptrT_AdaptiveCards__Inline_t_t(AdaptiveCardObjectModelJNI.Paragraph_GetInlines__SWIG_0(swigCPtr, this), false);
public InlineVector GetInlines() {
return new InlineVector(AdaptiveCardObjectModelJNI.Paragraph_GetInlines__SWIG_0(swigCPtr, this), false);
}

public static Paragraph Deserialize(ParseContext context, JsonValue root) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://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 class ParagraphVector extends java.util.AbstractList<Paragraph> implements java.util.RandomAccess {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;

protected ParagraphVector(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(ParagraphVector obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
AdaptiveCardObjectModelJNI.delete_ParagraphVector(swigCPtr);
}
swigCPtr = 0;
}
}

public ParagraphVector(Paragraph[] initialElements) {
this();
for (Paragraph element : initialElements) {
add(element);
}
}

public ParagraphVector(Iterable<Paragraph> initialElements) {
this();
for (Paragraph element : initialElements) {
add(element);
}
}

public Paragraph get(int index) {
return doGet(index);
}

public Paragraph set(int index, Paragraph e) {
return doSet(index, e);
}

public boolean add(Paragraph e) {
modCount++;
doAdd(e);
return true;
}

public void add(int index, Paragraph e) {
modCount++;
doAdd(index, e);
}

public Paragraph remove(int index) {
modCount++;
return doRemove(index);
}

protected void removeRange(int fromIndex, int toIndex) {
modCount++;
doRemoveRange(fromIndex, toIndex);
}

public int size() {
return doSize();
}

public ParagraphVector() {
this(AdaptiveCardObjectModelJNI.new_ParagraphVector__SWIG_0(), true);
}

public ParagraphVector(ParagraphVector other) {
this(AdaptiveCardObjectModelJNI.new_ParagraphVector__SWIG_1(ParagraphVector.getCPtr(other), other), true);
}

public long capacity() {
return AdaptiveCardObjectModelJNI.ParagraphVector_capacity(swigCPtr, this);
}

public void reserve(long n) {
AdaptiveCardObjectModelJNI.ParagraphVector_reserve(swigCPtr, this, n);
}

public boolean isEmpty() {
return AdaptiveCardObjectModelJNI.ParagraphVector_isEmpty(swigCPtr, this);
}

public void clear() {
AdaptiveCardObjectModelJNI.ParagraphVector_clear(swigCPtr, this);
}

public ParagraphVector(int count) {
this(AdaptiveCardObjectModelJNI.new_ParagraphVector__SWIG_2(count), true);
}

public ParagraphVector(int count, Paragraph value) {
this(AdaptiveCardObjectModelJNI.new_ParagraphVector__SWIG_3(count, Paragraph.getCPtr(value), value), true);
}

private int doSize() {
return AdaptiveCardObjectModelJNI.ParagraphVector_doSize(swigCPtr, this);
}

private void doAdd(Paragraph value) {
AdaptiveCardObjectModelJNI.ParagraphVector_doAdd__SWIG_0(swigCPtr, this, Paragraph.getCPtr(value), value);
}

private void doAdd(int index, Paragraph value) {
AdaptiveCardObjectModelJNI.ParagraphVector_doAdd__SWIG_1(swigCPtr, this, index, Paragraph.getCPtr(value), value);
}

private Paragraph doRemove(int index) {
long cPtr = AdaptiveCardObjectModelJNI.ParagraphVector_doRemove(swigCPtr, this, index);
return (cPtr == 0) ? null : new Paragraph(cPtr, true);
}

private Paragraph doGet(int index) {
long cPtr = AdaptiveCardObjectModelJNI.ParagraphVector_doGet(swigCPtr, this, index);
return (cPtr == 0) ? null : new Paragraph(cPtr, true);
}

private Paragraph doSet(int index, Paragraph value) {
long cPtr = AdaptiveCardObjectModelJNI.ParagraphVector_doSet(swigCPtr, this, index, Paragraph.getCPtr(value), value);
return (cPtr == 0) ? null : new Paragraph(cPtr, true);
}

private void doRemoveRange(int fromIndex, int toIndex) {
AdaptiveCardObjectModelJNI.ParagraphVector_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public void SetHorizontalAlignment(HorizontalAlignment value) {
AdaptiveCardObjectModelJNI.RichTextBlock_SetHorizontalAlignment(swigCPtr, this, value.swigValue());
}

public SWIGTYPE_p_std__vectorT_std__shared_ptrT_AdaptiveCards__Paragraph_t_t GetParagraphs() {
return new SWIGTYPE_p_std__vectorT_std__shared_ptrT_AdaptiveCards__Paragraph_t_t(AdaptiveCardObjectModelJNI.RichTextBlock_GetParagraphs__SWIG_0(swigCPtr, this), false);
public ParagraphVector GetParagraphs() {
return new ParagraphVector(AdaptiveCardObjectModelJNI.RichTextBlock_GetParagraphs__SWIG_0(swigCPtr, this), false);
}

public static RichTextBlock dynamic_cast(BaseCardElement baseCardElement) {
Expand Down
Loading