issues #795,#797, #798, #801, #803, #806 closed

parent 54299bdf
...@@ -23,6 +23,7 @@ public class ActionTalk implements Emitter.Listener { ...@@ -23,6 +23,7 @@ public class ActionTalk implements Emitter.Listener {
private Room room; private Room room;
Vector<iActionListener> listeners; Vector<iActionListener> listeners;
private static final String LOG_TAG=ActionTalk.class.getCanonicalName();
public ActionTalk(Room room, iActionListener listener) { public ActionTalk(Room room, iActionListener listener) {
this.room = room; this.room = room;
...@@ -41,13 +42,14 @@ public class ActionTalk implements Emitter.Listener { ...@@ -41,13 +42,14 @@ public class ActionTalk implements Emitter.Listener {
final String param_picto_cat="id_cat"; final String param_picto_cat="id_cat";
final String action_select="select"; final String action_select="select";
final String action_add="add"; final String action_add="add";
final String action_delete="delete";
final String action_show="show"; final String action_show="show";
JSONObject msg = (JSONObject) args[0]; JSONObject msg = (JSONObject) args[0];
try { try {
Log.i(this.getClass().getName(), "Received message (raw): " +msg.toString()+" mirror:"+PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()); Log.i(this.getClass().getName(), "Received message (raw): " +msg.toString()+" mirror:"+PCBcontext.getPcbdb().getCurrentUser().is_mirror_on());
String action = msg.getString(param_action).toLowerCase(); String action = msg.getString(param_action).toLowerCase();
if (action.equals(action_add) || action.equals(action_select) ||action.equals(action_show)) { if (action.equals(action_add) || action.equals(action_select) || action.equals(action_show) || action.equals(action_delete)) {
int picto_id; int picto_id;
int picto_cat; int picto_cat;
boolean mirroing=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on(); boolean mirroing=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on();
...@@ -62,14 +64,16 @@ public class ActionTalk implements Emitter.Listener { ...@@ -62,14 +64,16 @@ public class ActionTalk implements Emitter.Listener {
mirroing|=attrs_stu_picto.has(Picto.JSON_ATTTRS.MIRROR); mirroing|=attrs_stu_picto.has(Picto.JSON_ATTTRS.MIRROR);
} }
if ( mirroing) { if ( mirroing) {
Log.i(this.getClass().getName(), "Received message '" + action + Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat); "' for picto " + picto_id + " (cat " + picto_cat);
for (iActionListener listener : this.listeners) for (iActionListener listener : this.listeners)
listener.action(action.equals(action_add) listener.action(action.equals(action_add)
? iActionListener.action.add ? iActionListener.action.add
: action.equals(action_select) : action.equals(action_select)
? iActionListener.action.select ? iActionListener.action.select
: iActionListener.action.show : action.equals(action_delete)
? iActionListener.action.delete
: iActionListener.action.show
, picto_cat, picto_id); , picto_cat, picto_id);
} }
} }
...@@ -96,7 +100,7 @@ public class ActionTalk implements Emitter.Listener { ...@@ -96,7 +100,7 @@ public class ActionTalk implements Emitter.Listener {
* @version 1.0 * @version 1.0
*/ */
public interface iActionListener { public interface iActionListener {
enum action {add,select,show} enum action {add,delete,select,show}
void action(action action, int picto_cat, int picto_id); void action(action action, int picto_cat, int picto_id);
} }
} }
...@@ -7,6 +7,7 @@ import android.graphics.Color; ...@@ -7,6 +7,7 @@ import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
/** /**
* Created by Fernando on 15/03/2016. * Created by Fernando on 15/03/2016.
...@@ -157,4 +158,13 @@ public class BitmapTools { ...@@ -157,4 +158,13 @@ public class BitmapTools {
return this; return this;
} }
public void paint(BitmapDrawable drawable, double factor) {
Canvas canvas = new Canvas(this.bitmap);
int w=(int)(this.bitmap.getWidth()*factor);
int h=(int)(this.bitmap.getHeight()*factor);
canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(),
(int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null);
}
} }
...@@ -14,6 +14,7 @@ import android.view.View; ...@@ -14,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
...@@ -28,6 +29,8 @@ import java.util.Vector; ...@@ -28,6 +29,8 @@ import java.util.Vector;
* Created by Fernando on 18/12/2016. * Created by Fernando on 18/12/2016.
*/ */
class PictoAdapter extends BaseAdapter { class PictoAdapter extends BaseAdapter {
private String LOG_TAG=PictoAdapter.class.getCanonicalName();
public void setCurrentMsg(int currentMsg) { public void setCurrentMsg(int currentMsg) {
this.currentMsg = currentMsg; this.currentMsg = currentMsg;
} }
...@@ -36,11 +39,10 @@ class PictoAdapter extends BaseAdapter { ...@@ -36,11 +39,10 @@ class PictoAdapter extends BaseAdapter {
public static class Item { public static class Item {
Bitmap img; Bitmap img;
String secs; String secs;
StringBuilder sentence; String sentence="";
public Item(Bitmap img, String secs) { public Item(Bitmap img, String secs) {
this.img=img; this.img=img;
this.secs=secs; this.secs=secs;
this.sentence=new StringBuilder("");
} }
Bitmap getImg() { Bitmap getImg() {
return img; return img;
...@@ -49,9 +51,9 @@ class PictoAdapter extends BaseAdapter { ...@@ -49,9 +51,9 @@ class PictoAdapter extends BaseAdapter {
return secs; return secs;
} }
public String getMsg() { return sentence.toString();} public String getMsg() { return sentence.toString();}
public void setImg(Bitmap currmsg, String word) { public void setImg(Bitmap currmsg, String word, boolean eval) {
this.img=currmsg; this.img=currmsg;
sentence.append(" "+word); if (eval) sentence=": " +word;
} }
} }
Context context; Context context;
...@@ -103,9 +105,10 @@ public long getItemId(int position) { ...@@ -103,9 +105,10 @@ public long getItemId(int position) {
vi = inflater.inflate(R.layout.session_picto_view, null); vi = inflater.inflate(R.layout.session_picto_view, null);
ImageView picto=(ImageView)vi.findViewById(R.id.session_picto); ImageView picto=(ImageView)vi.findViewById(R.id.session_picto);
picto.setImageBitmap(this.msg.get(position).getImg()); picto.setImageBitmap(this.msg.get(position).getImg());
if (currentMsg== position) if (currentMsg== position) {
vi.setBackgroundColor(Color.LTGRAY); vi.setBackgroundColor(Color.LTGRAY);
else ((ListView)parent).smoothScrollToPosition(position);
}else
vi.setBackgroundColor(Color.TRANSPARENT); vi.setBackgroundColor(Color.TRANSPARENT);
return vi; return vi;
} }
...@@ -116,7 +119,7 @@ public long getItemId(int position) { ...@@ -116,7 +119,7 @@ public long getItemId(int position) {
bmp=set_text(context,bmp,getTimeDiff(new Date().getTime())); bmp=set_text(context,bmp,getTimeDiff(new Date().getTime()));
Bitmap currmsg=combineImages(oldmsg,bmp); Bitmap currmsg=combineImages(oldmsg,bmp);
item.setImg(currmsg,text); item.setImg(currmsg,text,false);
} }
...@@ -128,34 +131,30 @@ public long getItemId(int position) { ...@@ -128,34 +131,30 @@ public long getItemId(int position) {
float height = context.getResources().getDimension(R.dimen.picto_session_height); float height = context.getResources().getDimension(R.dimen.picto_session_height);
bmp=new BitmapTools(bmp).resize((int)width ,(int)height).get(); bmp=new BitmapTools(bmp).resize((int)width ,(int)height).get();
bmp=set_text(context,bmp,getTimeDiff(new Date().getTime())); bmp=set_text(context,bmp,getTimeDiff(new Date().getTime()));
Bitmap currmsg=this.currentMsg==this.msg.size()-1 ? combineImages(oldmsg,bmp) : updateImage(oldmsg,bmp); Bitmap currmsg = position>=this.msg.size()-1 ? combineImages(oldmsg,bmp) : updateImage(oldmsg,bmp);
item.setImg(currmsg,": "+evaluation); item.setImg(currmsg,evaluation,true);
} }
public int newMsg() { public int newMsg() {
Bitmap bmp=BitmapFactory.decodeResource(context.getResources(), if ((msg.size()>0 && msg.get(msg.size()-1).getImg().getWidth()>context.getResources().getDimension(R.dimen.picto_session_width)) || msg.size()==0)
R.drawable.application_online); {
float width =context.getResources().getDimension(R.dimen.picto_session_width); Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
float height = context.getResources().getDimension(R.dimen.picto_session_height); calendar.setTime(new Date()); // assigns calendar to given date
bmp=new BitmapTools(bmp).resize((int)width,(int)height).get(); String time = calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance Bitmap bmp = set_trycount(context,this.msg.size()+1);
calendar.setTime(new Date()); // assigns calendar to given date this.currentMsg = this.msg.size();
String time= calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND); msg.add(new Item(bmp, time));
bmp=set_text(context,bmp,time); }
this.currentMsg = this.msg.size();
msg.add(new Item(bmp, time));
return msg.size()-1; return msg.size()-1;
} }
private Bitmap combineImages(Bitmap c, Bitmap s) { private Bitmap combineImages(Bitmap c, Bitmap s) {
Bitmap cs = null; Bitmap cs = null;
int width, height = 0; int width, height = 0;
width = c.getWidth() + s.getWidth(); width = c.getWidth() + s.getWidth();
height = c.getHeight(); height = c.getHeight();
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs); Canvas comboImage = new Canvas(cs);
...@@ -163,31 +162,71 @@ public long getItemId(int position) { ...@@ -163,31 +162,71 @@ public long getItemId(int position) {
comboImage.drawBitmap(c, 0f, 0f, null); comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth(), 0f, null); comboImage.drawBitmap(s, c.getWidth(), 0f, null);
return cs; return cs;
} }
private Bitmap updateImage(Bitmap c, Bitmap s) { private Bitmap updateImage(Bitmap c, Bitmap s) {
Bitmap cs = null; Bitmap cs = null;
int width= c.getWidth(), height= c.getHeight(); int width= c.getWidth(), height= c.getHeight();
int cutwidth=c.getWidth()-s.getWidth(); int cutwidth=c.getWidth()-s.getWidth();
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs); Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(Bitmap.createBitmap(c,0,0,cutwidth,height), 0f, 0f, null); comboImage.drawBitmap(Bitmap.createBitmap(c,0,0,cutwidth,height), 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth()-s.getWidth(), 0f, null); comboImage.drawBitmap(s, cutwidth, 0f, null);
return cs; return cs;
} }
static void set_date(Context context, Canvas canvas,String time) {
TextView textView2 = new TextView(context);
textView2.layout(0, 20, 100, 100);
textView2.setPadding(0, 0, 0, 0);
textView2.setTextSize(TypedValue.COMPLEX_UNIT_PX, 13);
textView2.setTextColor(Color.BLACK);
textView2.setBackgroundColor(Color.LTGRAY);
textView2.setWidth(100);
textView2.setGravity(Gravity.CENTER_HORIZONTAL);
textView2.setMaxLines(1);
textView2.setText(time);
textView2.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView2.getDrawingCache(), 0, 60, null);
}
static Bitmap set_trycount(Context context,int pos) {
Bitmap param_bitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.try_border);
float width = context.getResources().getDimension(R.dimen.picto_session_width);
float height = context.getResources().getDimension(R.dimen.picto_session_height);
Bitmap bmp =Bitmap.createScaledBitmap(param_bitmap, (int)width, (int)height, false);
Canvas canvas = new Canvas(bmp);
TextView textView = new TextView(context);
String texto=(pos<10 ? "0" :"")+new Integer(pos).toString();
textView.layout(0, 0, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 40);
textView.setTextColor(Color.BLACK);
textView.setBackgroundColor(Color.TRANSPARENT);
textView.setWidth(100);
textView.setGravity(Gravity.LEFT);
textView.setMaxLines(1);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 10, 10, null);
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
calendar.setTime(new Date()); // assigns calendar to given date
String time= calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
set_date(context,canvas,time);
return bmp;
}
static Bitmap set_text(Context context,Bitmap param_bitmap,String texto) { static Bitmap set_text(Context context,Bitmap param_bitmap,String texto) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
float width = param_bitmap.getWidth(); float width = param_bitmap.getWidth();
float height=param_bitmap.getHeight(); float height=param_bitmap.getHeight();
android.graphics.Bitmap.Config bitmapConfig = param_bitmap.getConfig(); android.graphics.Bitmap.Config bitmapConfig = param_bitmap.getConfig();
if (bitmapConfig == null) { if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
} }
...@@ -199,20 +238,7 @@ public long getItemId(int position) { ...@@ -199,20 +238,7 @@ public long getItemId(int position) {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //Poner en blanco el bitmap original para dibujar encima canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //Poner en blanco el bitmap original para dibujar encima
canvas.drawBitmap(bm, 0, 0, paint); canvas.drawBitmap(bm, 0, 0, paint);
TextView textView = new TextView(context); set_date(context,canvas,texto);
textView.layout(0, 20, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 13);
textView.setTextColor(Color.BLACK);
textView.setBackgroundColor(Color.LTGRAY);
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setMaxLines(1);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 60, null);
return bitmap; return bitmap;
} }
...@@ -223,5 +249,7 @@ public long getItemId(int position) { ...@@ -223,5 +249,7 @@ public long getItemId(int position) {
public String getCurrentMsgText() { public String getCurrentMsgText() {
return this.getItem(currentMsg).getMsg(); return this.getItem(currentMsg).getMsg();
} }
public String getMsgText(int pos) {
return this.getItem(pos).getMsg();
}
} }
...@@ -3,9 +3,10 @@ package com.yottacode.pictogram.tabletlibrary.gui.session; ...@@ -3,9 +3,10 @@ package com.yottacode.pictogram.tabletlibrary.gui.session;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -25,9 +26,8 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -25,9 +26,8 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
interface iSessionFragment { interface iSessionFragment {
public void newMsg(int msg_pos);
public void selectedMsg(int msg_pos); public void selectedMsg(int msg_pos);
public void play_msg(int msg_pos); public void play_msg();
} }
private iSessionFragment mListener=null; private iSessionFragment mListener=null;
...@@ -39,6 +39,8 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -39,6 +39,8 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
public SessionFragment() { public SessionFragment() {
super();
} }
...@@ -46,7 +48,9 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -46,7 +48,9 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
adapter_pictomsg=new PictoAdapter(this.getContext());
setRetainInstance(true); setRetainInstance(true);
} }
@Override @Override
...@@ -55,7 +59,7 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -55,7 +59,7 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_session, container, false); View view = inflater.inflate(R.layout.fragment_session, container, false);
list_pictomsg = (ListView) view.findViewById(R.id.session_pictomsg_list); list_pictomsg = (ListView) view.findViewById(R.id.session_pictomsg_list);
adapter_pictomsg=new PictoAdapter(this.getContext());
list_pictomsg.setAdapter(adapter_pictomsg); list_pictomsg.setAdapter(adapter_pictomsg);
list_pictomsg.setOnItemClickListener(new AdapterView.OnItemClickListener() { list_pictomsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
...@@ -65,7 +69,6 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -65,7 +69,6 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
((PictoAdapter)list_pictomsg.getAdapter()).notifyDataSetChanged(); ((PictoAdapter)list_pictomsg.getAdapter()).notifyDataSetChanged();
} }
}); });
mListener.newMsg(this.adapter_pictomsg.getCount());
return view; return view;
} }
...@@ -106,20 +109,28 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -106,20 +109,28 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
@Override @Override
public void action(action action, int picto_cat, int picto_id) { public void action(action action, int picto_cat, int picto_id) {
if (action==ActionTalk.iActionListener.action.show) { if (action==ActionTalk.iActionListener.action.show) {
if (!paused) { if (!paused) {
mListener.play_msg(this.adapter_pictomsg.getCount()-1); mListener.play_msg();
mListener.newMsg(this.adapter_pictomsg.getCount());
} }
} else try { } else if (action==ActionTalk.iActionListener.action.add
|| action==ActionTalk.iActionListener.action.select
|| action==ActionTalk.iActionListener.action.delete) try {
Picto picto=PCBcontext.getVocabulary().get_picto(picto_cat,picto_id); Picto picto=PCBcontext.getVocabulary().get_picto(picto_cat,picto_id);
Bitmap bmp=picto.get_bitmap(getContext()); Bitmap bmp=picto.get_bitmap(getContext());
if (action==ActionTalk.iActionListener.action.delete) {
if (paused) { bmp = bmp.copy(bmp.getConfig(), true);
new BitmapTools(bmp).paint((BitmapDrawable)getActivity().getResources().getDrawable(R.drawable.disabled_picto,null),1);
} else if (PCBcontext.getVocabulary().get_picto(picto_cat,picto_id).is_category()) {
Log.e("CAT","catcat");
bmp = bmp.copy(bmp.getConfig(), true);
new BitmapTools(bmp).paint((BitmapDrawable)getActivity().getResources().getDrawable(R.drawable.session_category,null),0.5);
}
if (paused) {
bmp=bmp.copy(bmp.getConfig(),true); bmp=bmp.copy(bmp.getConfig(),true);
new BitmapTools(bmp).paintPause(); new BitmapTools(bmp).paintPause();
} }
this.adapter_pictomsg.addItem(bmp,picto.get_translation()); this.adapter_pictomsg.addItem(bmp,picto.get_translation());
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
public void run() { public void run() {
...@@ -162,4 +173,7 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe ...@@ -162,4 +173,7 @@ public class SessionFragment extends Fragment implements ActionTalk.iActionListe
public int get_last_msg_pos() { public int get_last_msg_pos() {
return adapter_pictomsg.getCount()-1; return adapter_pictomsg.getCount()-1;
} }
public String get_msg_text(int pos) {
return adapter_pictomsg.getMsgText(pos);
}
} }
...@@ -36,7 +36,7 @@ public class SessionWrapper { ...@@ -36,7 +36,7 @@ public class SessionWrapper {
public interface iStartSession { public interface iStartSession {
void started(int id_session); void started(int id_session, int first_try);
void error(String error); void error(String error);
} }
public interface iCloseSession { public interface iCloseSession {
...@@ -85,7 +85,7 @@ public class SessionWrapper { ...@@ -85,7 +85,7 @@ public class SessionWrapper {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
try { try {
listener.started(result.getInt("id")); listener.started(result.getInt("id"),result.getInt("first_try_id"));
} catch (JSONException e) { } catch (JSONException e) {
listener.error(e.getMessage()); listener.error(e.getMessage());
} }
...@@ -247,10 +247,10 @@ public class SessionWrapper { ...@@ -247,10 +247,10 @@ public class SessionWrapper {
Hashtable<String, String> params=new Hashtable<>(1); Hashtable<String, String> params=new Hashtable<>(1);
try { try {
params.put("json", new JSONObject() params.put("json", new JSONObject()
.put("ws", Integer.valueOf(ws).toString()) .put("ws", Integer.valueOf(ws).toString())
.put("supervisor",Integer.valueOf(PCBcontext.getPcbdb().getCurrentUser().get_id_sup()).toString()) .put("supervisor",Integer.valueOf(PCBcontext.getPcbdb().getCurrentUser().get_id_sup()).toString())
.put("student",Integer.valueOf(PCBcontext.getPcbdb().getCurrentUser().get_id_stu()).toString()) .put("student",Integer.valueOf(PCBcontext.getPcbdb().getCurrentUser().get_id_stu()).toString())
.put("begin",nowAsISO ).toString()); .put("begin",nowAsISO ).toString());
} catch (JSONException e) { } catch (JSONException e) {
Log.e(SessionWrapper.LOG_TAG,e.getMessage()); Log.e(SessionWrapper.LOG_TAG,e.getMessage());
listener.error(e.getMessage()); listener.error(e.getMessage());
...@@ -284,7 +284,8 @@ public class SessionWrapper { ...@@ -284,7 +284,8 @@ public class SessionWrapper {
}); });
} }
public static void evaluateTry(final int try_id, boolean now, String result, final iTryUpdated listener) { public static void evaluateTry(final int try_id, final boolean now, String result, final iTryUpdated listener) {
Hashtable<String, String> params=new Hashtable<>(1); Hashtable<String, String> params=new Hashtable<>(1);
try{ try{
JSONObject jparams=new JSONObject().put("result",result); JSONObject jparams=new JSONObject().put("result",result);
...@@ -295,7 +296,6 @@ public class SessionWrapper { ...@@ -295,7 +296,6 @@ public class SessionWrapper {
e.printStackTrace(); e.printStackTrace();
} }
PCBcontext.getRestapiWrapper().ask("try/"+try_id,params,"put",true, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask("try/"+try_id,params,"put",true, new RestapiWrapper.iRestapiListener() {
@Override @Override
...@@ -305,12 +305,20 @@ public class SessionWrapper { ...@@ -305,12 +305,20 @@ public class SessionWrapper {
@Override @Override
public void result(JSONArray result) { public void result(JSONArray result) {
listener.update(try_id); try {
listener.update(result.getJSONObject(0).getInt("next_try_id"));
} catch (JSONException e) {
listener.error(e.getMessage());
}
} }
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
listener.update(try_id); try {
listener.update(result.getInt("next_try_id"));
} catch (JSONException e) {
listener.error(e.getMessage());
}
} }
@Override @Override
......
...@@ -184,26 +184,22 @@ ...@@ -184,26 +184,22 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ScrollView <ListView
android:id="@+id/SCROLLER_ID" android:id="@+id/session_serverlog"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_toLeftOf="@+id/imageView3" android:layout_toLeftOf="@+id/imageView3"
android:layout_toRightOf="@+id/view_session_buttons0" android:layout_toRightOf="@+id/view_session_buttons0"
android:layout_below="@+id/view_as2" android:layout_below="@+id/view_as2"
android:layout_alignBottom="@+id/imageView3" android:layout_alignBottom="@+id/imageView3"
android:layout_alignTop="@+id/imageView3" android:layout_alignTop="@+id/imageView3"
android:fillViewport="true"> android:fillViewport="true"
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="12" android:ems="12"
android:id="@+id/session_serverlog"
android:layout_weight="1" android:layout_weight="1"
android:transcriptMode="alwaysScroll"
android:stackFromBottom="true"
android:background="@color/common_google_signin_btn_text_light_disabled" /> android:background="@color/common_google_signin_btn_text_light_disabled" />
</ScrollView>
<ImageView <ImageView
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<ListView <ListView
android:id="@+id/session_pictomsg_list" android:id="@+id/session_pictomsg_list"
android:transcriptMode="alwaysScroll"
android:stackFromBottom="true"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sessionLogEntry"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:gravity="left" />
...@@ -73,14 +73,6 @@ ...@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -89,6 +81,14 @@ ...@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment