Skip to content

Commit d0e7985

Browse files
committed
add alternative labels in json output
1 parent 1fecd5f commit d0e7985

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/edu/cmu/hcii/sugilite/SugiliteData.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ else if (currentBlock instanceof SugiliteOperationBlock){
137137
messageType, messageBody
138138
-------------------------
139139
"FINISHED_RECORDING", scriptName
140-
140+
"START_RECORDING_EXCEPTION", exceptionMessage
141+
"END_RECORDING_EXCEPTION", exceptionMessage
142+
"RUN_SCRIPT_EXCEPTION, exceptionMessage
143+
"RUN_JSON_EXCEPTION", exceptionMessage
144+
"ADD_JOSON_AS_SCRIPT_EXCEPTION", exceptionMessage
141145
142146
*/
143147
public String callbackString = "";
@@ -146,7 +150,12 @@ public void sendCallbackMsg(String messageType, String messageBody, String callb
146150
intent.putExtra("messageType", messageType);
147151
intent.putExtra("messageBody", messageBody);
148152
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
149-
startActivity(intent);
153+
try {
154+
startActivity(intent);
155+
}
156+
catch (Exception e){
157+
//do nothing
158+
}
150159
}
151160

152161

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package edu.cmu.hcii.sugilite.communication.json;
2+
3+
/**
4+
* @author toby
5+
* @date 8/1/16
6+
* @time 3:28 PM
7+
*/
8+
public class SugiliteAlternativePairJSON {
9+
public String type, value;
10+
public SugiliteAlternativePairJSON(String type, String value){
11+
this.type = type;
12+
this.value = value;
13+
}
14+
}

app/src/main/java/edu/cmu/hcii/sugilite/communication/json/SugiliteFilterJSON.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.graphics.Rect;
44

5+
import java.util.AbstractMap;
56
import java.util.HashSet;
67
import java.util.Map;
78
import java.util.Set;
@@ -25,8 +26,12 @@ public SugiliteFilterJSON(UIElementMatchingFilter filter){
2526
this.parentFilter = new SugiliteFilterJSON(filter.getParentFilter());
2627
if(filter.getChildFilter() != null)
2728
this.childFilter = new SugiliteFilterJSON(filter.getChildFilter());
28-
if(filter.alternativeLabels != null && filter.alternativeLabels.size() > 0)
29-
alternativeLabels = new HashSet<>(filter.alternativeLabels);
29+
if(filter.alternativeLabels != null && filter.alternativeLabels.size() > 0) {
30+
this.alternativeLabels = new HashSet<>();
31+
for(Map.Entry<String, String> entry : filter.alternativeLabels){
32+
this.alternativeLabels.add(new SugiliteAlternativePairJSON(entry.getKey(), entry.getValue()));
33+
}
34+
}
3035
}
3136
}
3237
public UIElementMatchingFilter toUIElementMatchingFilter(){
@@ -44,11 +49,15 @@ public UIElementMatchingFilter toUIElementMatchingFilter(){
4449
filter.setParentFilter(parentFilter.toUIElementMatchingFilter());
4550
if(childFilter != null)
4651
filter.setChildFilter(childFilter.toUIElementMatchingFilter());
47-
if(alternativeLabels != null)
48-
filter.alternativeLabels = new HashSet<>(alternativeLabels);
52+
if(alternativeLabels != null) {
53+
filter.alternativeLabels = new HashSet<>();
54+
for(SugiliteAlternativePairJSON pair : alternativeLabels){
55+
filter.alternativeLabels.add(new AbstractMap.SimpleEntry<String, String>(pair.type, pair.value));
56+
}
57+
}
4958
return filter;
5059
}
5160
public String text, contentDescription, viewId, packageName, className, boundsInScreen, boundsInParent;
5261
public SugiliteFilterJSON parentFilter, childFilter;
53-
public Set<Map.Entry<String, String>> alternativeLabels;
62+
public Set<SugiliteAlternativePairJSON> alternativeLabels;
5463
}

app/src/main/java/edu/cmu/hcii/sugilite/model/block/SugiliteAvailableFeaturePack.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ public SugiliteAvailableFeaturePack(SugiliteAvailableFeaturePack featurePack){
3232
this.parentNode = featurePack.parentNode;
3333
this.childNodes = new ArrayList<>(featurePack.childNodes);
3434
this.allNodes = new ArrayList<>(featurePack.allNodes);
35-
this.alternativeChildTextList = new HashSet<>(alternativeTextList);
36-
this.alternativeTextList = new HashSet<>(alternativeTextList);
35+
if(featurePack.alternativeChildTextList != null)
36+
this.alternativeChildTextList = new HashSet<>(featurePack.alternativeChildTextList);
37+
else
38+
this.alternativeChildTextList = new HashSet<>();
39+
if(featurePack.alternativeTextList != null)
40+
this.alternativeTextList = new HashSet<>(featurePack.alternativeTextList);
41+
else
42+
this.alternativeTextList = new HashSet<>();
3743
}
3844
public String packageName, className, text, contentDescription, viewId, boundsInParent, boundsInScreen;
3945
public boolean isEditable;

0 commit comments

Comments
 (0)