Skip to content

Commit

Permalink
Merge pull request #393 from synaptek/Math_Update
Browse files Browse the repository at this point in the history
Added operator highlight in Tutorial -
  • Loading branch information
synaptek authored Jun 9, 2017
2 parents 66c3e33 + 4aaabbf commit a584956
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 44 deletions.
3 changes: 2 additions & 1 deletion app/src/main/assets/tutors/add_subtract/animator_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@
{"name": "LOG_EVENT", "type": "QUEUEDCOMMAND", "id": "SAddSubtract", "method": "logState", "parms": "type#feedback,value#MATH_INSTRUCTION_ADD_BEHAVIOR:String", "features":""},

{"name":"Introduction Audio", "type": "QUEUEDAUDIO", "command": "PLAY", "soundsource": "Lets add some numbers now.mp3", "soundpackage":"default", "volume": 1.0, "mode":"flow", "features": ""},

{"name":"Zoom Operator:", "type": "QUEUEDCOMMAND", "id": "SAddSubtract", "method": "zoomOperator", "features": ""},
{"name":"This is ...", "type": "QUEUEDAUDIO", "command": "PLAY", "soundsource": "This is called a plus sign.mp3", "soundpackage":"default", "volume": 1.0, "mode":"flow", "features": ""},

{"name":"Show Scaffold:", "type": "QUEUEDCOMMAND", "id": "SAddSubtract", "method": "setDotBagsVisible", "parms":"TRUE:Boolean", "features": ""},

{"name":"Adding 3 + 2...", "type": "QUEUEDAUDIO", "command": "PLAY", "soundsource": "Adding 3 things plus 2 things means--.mp3", "soundpackage":"default", "volume": 1.0, "mode":"flow", "features": ""},
{"name":"Let's Tap...", "type": "QUEUEDAUDIO", "command": "PLAY", "soundsource": "Lets tap on the three things to add them to the two things.mp3", "soundpackage":"default", "volume": 1.0, "mode":"flow", "features": ""}
],
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/assets/tutors/bubble_pop/animator_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@
{"type": "COMMAND", "id": "SBubblePop", "method": "setVolatileBehavior", "parms": "BUBBLES_CLEARED:String|NEXTNODE:String" ,"features":"FTR_LASTATTEMPT"},
{"type": "COMMAND", "id": "SBubblePop", "method": "postEvent", "parms": "CLEAR_CONTENT:String" ,"features":"FTR_LASTATTEMPT"},
{"type": "COMMAND", "cmd": "WAIT" ,"features":"FTR_LASTATTEMPT" },
{"type": "COMMAND", "id": "SBubblePop", "method": "postEvent", "parms": "HIDE_MASK:String" ,"features":"FTR_LASTATTEMPT"},
{"type": "COMMAND", "id": "SBubblePop", "method": "postEvent", "parms": "HIDE_MASK:String" ,"features":"FTR_LASTATTEMPT"}

{"type": "TIMER", "id":"nextDelayTimer", "startdelay":"0", "period":"750", "repeat":"false", "action":"CREATEANDSTART", "ontimer":"NEXTNODE", "features": "" },
{"type": "COMMAND", "cmd": "WAIT" }
// TODO: is this delay required removed in 45.1
//
// {"type": "TIMER", "id":"nextDelayTimer", "startdelay":"0", "period":"50", "repeat":"false", "action":"CREATEANDSTART", "ontimer":"NEXTNODE", "features": "" },
// {"type": "COMMAND", "cmd": "WAIT" }
]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@
import static cmu.xprize.comp_clickmask.CM_CONST.EXCLUDE_CIRCLE;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_ADDEXCL;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_ALPHA;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_ANIMATE;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_CLREXCL;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_R;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_SETALPHA;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_SHOWHIDE;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_TYPE;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_X;
import static cmu.xprize.comp_clickmask.CM_CONST.MASK_Y;
import static cmu.xprize.util.TCONST.INVISIBLE;
import static cmu.xprize.util.TCONST.QGRAPH_MSG;
import static cmu.xprize.util.TCONST.TUTOR_STATE_MSG;
import static cmu.xprize.util.TCONST.VISIBLE;

public class TBpComponent extends CBP_Component implements IBehaviorManager, ITutorObjectImpl, IDataSink, IEventSource, IPublisher, ITutorLogger {

Expand Down Expand Up @@ -307,7 +310,7 @@ public void maskBubble() {
// Show the mask while the feedback is in progress
//
msg = new Intent(MASK_SHOWHIDE);
msg.putExtra(MASK_SHOWHIDE, true);
msg.putExtra(MASK_SHOWHIDE, VISIBLE);

bManager.sendBroadcast(msg);
}
Expand All @@ -324,7 +327,7 @@ public void clearMask() {
// Hide the mask
//
msg = new Intent(MASK_SHOWHIDE);
msg.putExtra(MASK_SHOWHIDE, false);
msg.putExtra(MASK_SHOWHIDE, INVISIBLE);

bManager.sendBroadcast(msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;

import cmu.xprize.comp_clickmask.CClickMask;
import cmu.xprize.comp_clickmask.CExclusion;
import cmu.xprize.comp_clickmask.IMaskOwner;
import cmu.xprize.robotutor.R;
import cmu.xprize.robotutor.tutorengine.CSceneDelegate;
Expand All @@ -45,7 +43,7 @@ public class TScenePercentLayout extends PercentRelativeLayout implements ITutor
private Context mContext;
private CSceneDelegate mTutorScene;
private TClickMask mMask;
private boolean isMasked = true;
private int mMaskState = GONE;

final private String TAG = "TScenePercentLayout";

Expand Down Expand Up @@ -90,7 +88,7 @@ protected void onFinishInflate() {
mMask.setLayoutParams(lp);

addView(mMask);
setMasked(false);
setMasked(GONE);

bringChildToFront(mMask);
}
Expand All @@ -106,20 +104,20 @@ public void onDestroy() {
*
* @param _mask
*/
public void setMasked(boolean _mask) {
public void setMasked(int _mask) {

mMask.setVisibility(_mask? VISIBLE:INVISIBLE);
mMask.setVisibility(_mask);

if(_mask)
if(_mask == VISIBLE)
bringChildToFront(mMask);

isMasked = _mask;
mMaskState = _mask;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

if (isMasked) {
if (mMaskState == VISIBLE) {
return true;
} else {
return false;
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/add_subtract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
app:layout_marginRightPercent="0%"
app:layout_marginLeftPercent="5%" />


<cmu.xprize.robotutor.tutorengine.widgets.core.THandAnimation
android:id="@+id/ShandAnimator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
app:scale_factor="0.3"
android:background="@null"/>

</cmu.xprize.robotutor.tutorengine.widgets.core.TScenePercentLayout>


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {

// Semantic versioning description:
// <Milestone release> <Feature Release> <Patch release> <Asset Compatibility INDEX>
rtVersionName="0.44.1.1"
rtVersionName="0.46.0.1"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class CBP_Component extends FrameLayout implements IEventDispatcher, ILoa


// Working data sets
//

public ArrayList<String> wrk_responseSet = null; // set of response tems
public ArrayList<String> wrk_respTypeSet = null; // text/reference - for mixed response sets
public ArrayList<String[]> wrk_response_script = null; // List of uttereances describing each potential response
Expand Down
115 changes: 106 additions & 9 deletions comp_clickmask/src/main/java/cmu/xprize/comp_clickmask/CClickMask.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package cmu.xprize.comp_clickmask;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -24,6 +26,7 @@
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.util.AttributeSet;
Expand All @@ -32,13 +35,17 @@

import java.util.ArrayList;

import cmu.xprize.comp_logging.CLogManager;
import cmu.xprize.comp_logging.ILogManager;
import cmu.xprize.util.CAnimatorUtil;
import cmu.xprize.util.CDisplayMetrics;
import cmu.xprize.util.TCONST;

import static android.view.View.GONE;
import static cmu.xprize.comp_clickmask.CM_CONST.*;


public class CClickMask extends View implements View.OnTouchListener {
public class CClickMask extends View implements Animator.AnimatorListener {


public Context mContext;
Expand All @@ -54,10 +61,15 @@ public class CClickMask extends View implements View.OnTouchListener {
private RectF border = new RectF();
private ArrayList<CExclusion> exclusions;
private int[] _screenCoord = new int[2];
private boolean deferredHide = false;

private LocalBroadcastManager bManager;
private ChangeReceiver bReceiver;

public ILogManager logManager;

private final String TAG = "CClickMask";


public CClickMask(Context context) {
super(context);
Expand Down Expand Up @@ -89,9 +101,12 @@ protected void init(Context context, AttributeSet attrs) {
filter.addAction(MASK_ADDEXCL);
filter.addAction(MASK_CLREXCL);
filter.addAction(MASK_SETALPHA);
filter.addAction(MASK_ANIMATE);

bReceiver = new ChangeReceiver();

logManager = CLogManager.getInstance();

bManager.registerReceiver(bReceiver, filter);
}

Expand All @@ -100,11 +115,13 @@ public void setOwner(IMaskOwner _owner) {
mOwner = _owner;
}

public void showHide(boolean _show) {

public void showHide(int _show) {

mOwner.setMasked(_show);
}


public void setMaskColor(int newColor) {

mPaint.setColor(newColor);
Expand Down Expand Up @@ -132,17 +149,101 @@ public void clearExclusions() {
}


@Override
public void setVisibility(int visibility) {

switch(visibility) {

case VISIBLE:
deferredHide = false;
setAlpha(0);
super.setVisibility(visibility);
break;

case INVISIBLE:
deferredHide = true;
break;

case GONE:
super.setVisibility(visibility);
break;
}
}



//************************************************************************
//************************************************************************
// AnimatorListener Start


@Override
public void onAnimationStart(Animator animator) {

}

@Override
public void onAnimationEnd(Animator animator) {

if(deferredHide)
super.setVisibility(INVISIBLE);
}

@Override
public void onAnimationCancel(Animator animator) {

if(deferredHide)
super.setVisibility(INVISIBLE);
}

@Override
public void onAnimationRepeat(Animator animator) {

}

// AnimatorListener End
//************************************************************************
//************************************************************************



class ChangeReceiver extends BroadcastReceiver {

public void onReceive (Context context, Intent intent) {

switch(intent.getAction()) {

case MASK_SHOWHIDE:
Boolean showmask = intent.getBooleanExtra(MASK_SHOWHIDE, false);

int showmask = intent.getIntExtra(MASK_SHOWHIDE, GONE);

showHide(showmask);

// Animate the mask
//
Intent msg = new Intent(MASK_ANIMATE);

bManager.sendBroadcast(msg);

break;

case MASK_ANIMATE:

Animator fader;

if(deferredHide) {
fader = CAnimatorUtil.configFadeOut(CClickMask.this, CM_CONST.FADE_TIME);
}
else {
fader = CAnimatorUtil.configFadeIn(CClickMask.this, CM_CONST.FADE_TIME);
}
fader.start();

break;

// NOTE: Must invalidate when changing exclusions so that onDraw is called before
// animation to refresh the animation cache.
//
case MASK_ADDEXCL:
String exclusiontype = intent.getStringExtra(MASK_TYPE);

Expand All @@ -160,12 +261,14 @@ public void onReceive (Context context, Intent intent) {
exclusiony -= _screenCoord[1];

addExclusion(new CExclusion(exclusiontype, exclusionx, exclusiony, exclusionr));
invalidate();
break;
}
break;

case MASK_CLREXCL:
clearExclusions();
invalidate();
break;

case MASK_SETCOLOR:
Expand Down Expand Up @@ -209,10 +312,4 @@ public void onDraw(Canvas canvas) {
canvas.drawPath(mask, mPaint);
}


@Override
public boolean onTouch(View view, MotionEvent motionEvent) {

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public class CM_CONST {

public static final String MASK_ANIMATE = "MASK_ANIMATE";
public static final String MASK_SHOWHIDE = "MASK_SHOWHIDE";
public static final String MASK_ADDEXCL = "MASK_ADDEXCL";
public static final String MASK_CLREXCL = "MASK_CLREXCL";
Expand All @@ -28,5 +29,6 @@ public class CM_CONST {
public static final String MASK_COLOR = "MASK_COLOR";
public static final String MASK_ALPHA = "MASK_ALPHA";

public static final String EXCLUDE_CIRCLE = "EXCLUDE_CIRCLE";
public static final String EXCLUDE_CIRCLE = "EXCLUDE_CIRCLE";
public static final long FADE_TIME = 200;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

public interface IMaskOwner {

public void setMasked(boolean _mask);
public void setMasked(int _mask);

}
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ public void run() {
// We always start the thread in the paused state
//
if (isPausedRecognizer) {

try {
recorder.stop();
isRecording = false;
Expand Down
Loading

0 comments on commit a584956

Please sign in to comment.