Skip to content

Commit

Permalink
add alternative labels in json output
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyli committed Aug 1, 2016
1 parent 1fecd5f commit d0e7985
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions app/src/main/java/edu/cmu/hcii/sugilite/SugiliteData.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ else if (currentBlock instanceof SugiliteOperationBlock){
messageType, messageBody
-------------------------
"FINISHED_RECORDING", scriptName
"START_RECORDING_EXCEPTION", exceptionMessage
"END_RECORDING_EXCEPTION", exceptionMessage
"RUN_SCRIPT_EXCEPTION, exceptionMessage
"RUN_JSON_EXCEPTION", exceptionMessage
"ADD_JOSON_AS_SCRIPT_EXCEPTION", exceptionMessage
*/
public String callbackString = "";
Expand All @@ -146,7 +150,12 @@ public void sendCallbackMsg(String messageType, String messageBody, String callb
intent.putExtra("messageType", messageType);
intent.putExtra("messageBody", messageBody);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
try {
startActivity(intent);
}
catch (Exception e){
//do nothing
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package edu.cmu.hcii.sugilite.communication.json;

/**
* @author toby
* @date 8/1/16
* @time 3:28 PM
*/
public class SugiliteAlternativePairJSON {
public String type, value;
public SugiliteAlternativePairJSON(String type, String value){
this.type = type;
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Rect;

import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -25,8 +26,12 @@ public SugiliteFilterJSON(UIElementMatchingFilter filter){
this.parentFilter = new SugiliteFilterJSON(filter.getParentFilter());
if(filter.getChildFilter() != null)
this.childFilter = new SugiliteFilterJSON(filter.getChildFilter());
if(filter.alternativeLabels != null && filter.alternativeLabels.size() > 0)
alternativeLabels = new HashSet<>(filter.alternativeLabels);
if(filter.alternativeLabels != null && filter.alternativeLabels.size() > 0) {
this.alternativeLabels = new HashSet<>();
for(Map.Entry<String, String> entry : filter.alternativeLabels){
this.alternativeLabels.add(new SugiliteAlternativePairJSON(entry.getKey(), entry.getValue()));
}
}
}
}
public UIElementMatchingFilter toUIElementMatchingFilter(){
Expand All @@ -44,11 +49,15 @@ public UIElementMatchingFilter toUIElementMatchingFilter(){
filter.setParentFilter(parentFilter.toUIElementMatchingFilter());
if(childFilter != null)
filter.setChildFilter(childFilter.toUIElementMatchingFilter());
if(alternativeLabels != null)
filter.alternativeLabels = new HashSet<>(alternativeLabels);
if(alternativeLabels != null) {
filter.alternativeLabels = new HashSet<>();
for(SugiliteAlternativePairJSON pair : alternativeLabels){
filter.alternativeLabels.add(new AbstractMap.SimpleEntry<String, String>(pair.type, pair.value));
}
}
return filter;
}
public String text, contentDescription, viewId, packageName, className, boundsInScreen, boundsInParent;
public SugiliteFilterJSON parentFilter, childFilter;
public Set<Map.Entry<String, String>> alternativeLabels;
public Set<SugiliteAlternativePairJSON> alternativeLabels;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ public SugiliteAvailableFeaturePack(SugiliteAvailableFeaturePack featurePack){
this.parentNode = featurePack.parentNode;
this.childNodes = new ArrayList<>(featurePack.childNodes);
this.allNodes = new ArrayList<>(featurePack.allNodes);
this.alternativeChildTextList = new HashSet<>(alternativeTextList);
this.alternativeTextList = new HashSet<>(alternativeTextList);
if(featurePack.alternativeChildTextList != null)
this.alternativeChildTextList = new HashSet<>(featurePack.alternativeChildTextList);
else
this.alternativeChildTextList = new HashSet<>();
if(featurePack.alternativeTextList != null)
this.alternativeTextList = new HashSet<>(featurePack.alternativeTextList);
else
this.alternativeTextList = new HashSet<>();
}
public String packageName, className, text, contentDescription, viewId, boundsInParent, boundsInScreen;
public boolean isEditable;
Expand Down

0 comments on commit d0e7985

Please sign in to comment.