auto indent files

parent 6787d27c
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.tabletlibrary">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:allowBackup="true"
......
......@@ -116,9 +116,9 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
protected boolean deleting;
protected boolean tape_delivered=false;
protected boolean tape_delivered = false;
float firstTouchX = -1;
public boolean inserting=false;
public boolean inserting = false;
@TargetApi(Build.VERSION_CODES.M)
@Override
......@@ -130,7 +130,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
// after a long inactivity, the pcbdb is discarded
if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"PCBDB was discarded. App restarting");
Log.i(LOG_TAG, "PCBDB was discarded. App restarting");
NetServiceTablet.restart_PictogramTablet(this);
return;
}
......@@ -152,35 +152,35 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
@Override
public void action(action action, int picto_cat, int picto_id, JSONObject msg) {
Log.i(this.getClass().getCanonicalName(), action + " from " + picto_cat + "," + picto_id + " catched");
if (action==ActionTalk.iActionListener.action.show) {
if (action == ActionTalk.iActionListener.action.show) {
Log.i("TAG_PRUEBAS","show message received:"+msg.toString());
Log.i("TAG_PRUEBAS", "show message received:" + msg.toString());
JSONObject msg_attrs = null;
JSONArray pictos = null;
String mensaje= "";
String mensaje = "";
try {
msg_attrs = msg.getJSONObject("attributes");
pictos = msg_attrs.getJSONArray("pictos");
String user = pictos.getJSONObject(0).getJSONObject("attributes").getString("user_avatar");
if(user.equals(PCBcontext.getPcbdb().getCurrentUser().get_email_sup())){ //si el primer picto tiene ese sup asociado
mensaje += getResources().getString(R.string.message_from)+": "+PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+", "+ PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+"\n";
mensaje += getResources().getString(R.string.says)+": ";
for(int i = 0; i < pictos.length(); i++) {
if (user.equals(PCBcontext.getPcbdb().getCurrentUser().get_email_sup())) { //si el primer picto tiene ese sup asociado
mensaje += getResources().getString(R.string.message_from) + ": " + PCBcontext.getPcbdb().getCurrentUser().get_name_stu() + ", " + PCBcontext.getPcbdb().getCurrentUser().get_surname_stu() + "\n";
mensaje += getResources().getString(R.string.says) + ": ";
for (int i = 0; i < pictos.length(); i++) {
JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes");
mensaje += (i != pictos.length()-1 ? picto.get("expression").toString()+" - " : picto.get("expression").toString());
mensaje += (i != pictos.length() - 1 ? picto.get("expression").toString() + " - " : picto.get("expression").toString());
}
Log.i(LOG_TAG,"Mensaje: "+msg.toString());
Log.i(LOG_TAG, "Mensaje: " + msg.toString());
final AlertDialog.Builder builder = new AlertDialog.Builder(VOCA.this);
builder.setMessage(mensaje)
.setPositiveButton("Vale", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
.setPositiveButton("Vale", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
}
});
// Create the AlertDialog object and return it
runOnUiThread(new Runnable() {
@Override
......@@ -196,9 +196,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
}
else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
} else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
Picto picto = vocabulary.get_picto(picto_cat, picto_id);
VOCA.this.execHighligthFeeback(picto, true);
}
......@@ -267,12 +265,12 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
this.tapeGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!deleting) {
Log.i(VOCA.class.getCanonicalName(), " Deleting item " + position + "-" + id + "(" + VOCA.this.tapeAdapter.getItem(position).get_translation() + ")");
Picto deletedPicto=VOCA.this.tapeAdapter.getItem(position);
Picto deletedPicto = VOCA.this.tapeAdapter.getItem(position);
new PictoAnimation().animateOnDeleteView(VOCA.this,view, position);
new PictoAnimation().animateOnDeleteView(VOCA.this, view, position);
VOCA.this.tapeAdapter.notifyDataSetChanged();
if (pictoMainGridAdapter.pictoInThisCategory(deletedPicto))
pictoMainGridAdapter.pictoInGrid(deletedPicto);
......@@ -280,7 +278,8 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
pictoCategoryGridAdapter.pictoInGrid(deletedPicto);
PCBcontext.getActionLog().log(new TalkAction(TalkAction.DELETE, deletedPicto));
}
}});
}
});
((NetServiceTablet) PCBcontext.getNetService().getNetServiceDevice()).setVOCA(this);
if (PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big()) {
......@@ -314,11 +313,11 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
PCBcontext.setActivityContext(this);
setConfig();
startTTS();
Toast.makeText(this.getBaseContext(), PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+
(PCBcontext.getPcbdb().getCurrentUser().is_supervisor()
? " ("+ PCBcontext.getPcbdb().getCurrentUser().get_name_sup()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_sup()+")"
:"")
, Toast.LENGTH_SHORT).show();
Toast.makeText(this.getBaseContext(), PCBcontext.getPcbdb().getCurrentUser().get_name_stu() + " " + PCBcontext.getPcbdb().getCurrentUser().get_surname_stu() +
(PCBcontext.getPcbdb().getCurrentUser().is_supervisor()
? " (" + PCBcontext.getPcbdb().getCurrentUser().get_name_sup() + " " + PCBcontext.getPcbdb().getCurrentUser().get_surname_sup() + ")"
: "")
, Toast.LENGTH_SHORT).show();
}
public void setConfig() {
......@@ -335,45 +334,45 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
View.OnTouchListener touchListener;
touchListener =
vibration ? new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean enable_haptic;
enable_haptic = !(v instanceof GridView);
if (!enable_haptic) {
int x = Math.round(event.getX());
int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y);
Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null;
enable_haptic = (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled());
}
if (enable_haptic)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
vibration ? new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean enable_haptic;
enable_haptic = !(v instanceof GridView);
if (!enable_haptic) {
int x = Math.round(event.getX());
int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y);
Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null;
enable_haptic = (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled());
}
if (enable_haptic)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
return false;
}
}
: click
? new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return false;
}
}
: new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
: click
? new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
};
: new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
};
for (View view : views)
view.setOnTouchListener(touchListener);
......@@ -381,13 +380,13 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
public void startTTS() {
String engine = PCBcontext.getPcbdb().getCurrentUser().get_tts_engine_sup() == null
? getString(R.string.default_tts_engine)
: PCBcontext.getPcbdb().getCurrentUser().get_tts_engine_sup();
? getString(R.string.default_tts_engine)
: PCBcontext.getPcbdb().getCurrentUser().get_tts_engine_sup();
String tts_voice = PCBcontext.getPcbdb().getCurrentUser().get_json_attr("tts voice") == null
? PCBcontext.getPcbdb().getCurrentUser().get_gender_stu().charAt(0) == 'M'
? getString(R.string.default_tts_voice_male)
: getString(R.string.default_tts_voice_female)
: PCBcontext.getPcbdb().getCurrentUser().get_json_attr("tts voice");
? PCBcontext.getPcbdb().getCurrentUser().get_gender_stu().charAt(0) == 'M'
? getString(R.string.default_tts_voice_male)
: getString(R.string.default_tts_voice_female)
: PCBcontext.getPcbdb().getCurrentUser().get_json_attr("tts voice");
tts = new TTSHelper(this, engine, new Locale(PCBcontext.getPcbdb().getCurrentUser().get_lang_stu()), tts_voice);
......@@ -422,6 +421,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
this.pictoCategoryGridAdapter.allPictosInGrid();
this.pictoMainGridAdapter.allPictosInGrid();
}
@Override
protected void onStop() {
super.onStop();
......@@ -552,17 +552,17 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
// This is to show the pictos ordered in the 2D Array that represents the panel
Picto[][] mp = new Picto[maxRows][maxColumns];
Iterator<Picto> pictos=list.iterator();
Iterator<Picto> pictos = list.iterator();
while (pictos.hasNext()) {
Picto p= pictos.next();
Picto p = pictos.next();
if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().has_categories()) {
if (p.get_column() != -1 && p.get_row() != -1
&& p.get_column() < maxRows && p.get_row() < maxColumns) {
&& p.get_column() < maxRows && p.get_row() < maxColumns) {
mp[p.get_column()][p.get_row()] = p;
}
} else {
if (p.getFreeColumn() != -1 && p.getFreeRow() != -1
&& p.getFreeColumn() < maxRows && p.getFreeRow() < maxColumns) {
&& p.getFreeColumn() < maxRows && p.getFreeRow() < maxColumns) {
mp[p.getFreeColumn()][p.getFreeRow()] = p;
}
}
......@@ -578,7 +578,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
for (int i = 0; i < maxRows; i++)
for (int j = 0; j < maxColumns; j++)
ll.add(mp[i][j]);
ll.add(mp[i][j]);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -709,18 +709,18 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
}
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
}
}
/**
......@@ -738,7 +738,6 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
/**
*
* @return
*/
public Picto getCurrentCategory() {
......@@ -782,12 +781,12 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
ViewGroup viewgroup = (ViewGroup) view.getParent();
int position = Integer.parseInt((String) event.getClipDescription().getLabel());
Log.d("Drag:", "Posición: " + position + " es categoria:" + v.getTransitionName()+" "+viewgroup.getTransitionName());
Log.d("Drag:", "Posición: " + position + " es categoria:" + v.getTransitionName() + " " + viewgroup.getTransitionName());
// if the view is the tape_grid_view, we accept the drag item
// Destino tape_grid_view y origen panel_grid_view
if (v == findViewById(R.id.tape_grid_view) && (viewgroup == findViewById(R.id.picto_category_grid_view) || viewgroup == findViewById(R.id.picto_main_grid_view))) {
Picto p = viewgroup == findViewById(R.id.picto_category_grid_view) ? pictoCategoryGridAdapter.getItem(position)
: pictoMainGridAdapter.getItem(position);
: pictoMainGridAdapter.getItem(position);
if (!p.is_category()) addPictoWord(view, p);
}
......@@ -813,7 +812,8 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
}
/**f
/**
* f
* Class used for picto clicking feedback
*/
private class OnPictoClickListener implements AdapterView.OnItemClickListener {
......@@ -823,7 +823,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled()) {
p.set_mirror(false, false);
p.set_mirror(false, false);
// If the picto is a category
if (p.is_category()) {
......@@ -832,7 +832,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
hidePictoMainGridView();
} else if (tapeAdapter.getCount() < VOCA.this.maxInTape && !VOCA.this.tapeAdapter.play()) {
addPictoWord(parent.getChildAt(position),p);
addPictoWord(parent.getChildAt(position), p);
}
}
......@@ -840,30 +840,28 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
/**
*
* @param view
* @param p
*/
private void addPictoWord(View view, Picto p) {
tapeAdapter.addItem(p);
getCurrentPictoGridAdapter().pictoInTape(view,p);
getCurrentPictoGridAdapter().pictoInTape(view, p);
currentCategory = null;
tapeAdapter.notifyDataSetChanged();
showPictoMainGridView();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.ADD, p));
if (VOCA.this.feedback_read && !VOCA.this.tapeAdapter.play() && !p.is_category()) {
File audioFile = p.get_audioFile();
Log.e(LOG_TAG,"AUDIO:"+(audioFile!=null)+":"+p.get_audioPath());
Log.e(LOG_TAG, "AUDIO:" + (audioFile != null) + ":" + p.get_audioPath());
if (audioFile != null)
VOCA.this.tts.playRecord(audioFile);
else
else
VOCA.this.tts.play(p.get_translation());
}
if (VOCA.this.feedback_highlight) execHighligthFeeback(p, false);
}
/**
*
* @param picto
* @param highlight_background
*/
......@@ -886,6 +884,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
prev_picto = picto;
exec_mirror.scheduleAtFixedRate(new Runnable() {
int repeating = 0;
@Override
public void run() {
refresh();
......@@ -902,6 +901,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
// TODO: REVISAR
/**
* Class used for long pressing on pictos (start drag)
*/
......@@ -915,15 +915,15 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
if (p != null && !p.is_invisible() && p.is_enabled()) {
// If is not the blank picto, it isn't invisible or disabled
if (p.get_id() != 0 &&
!p.get_status().equalsIgnoreCase("invisible") &&
!p.get_status().equalsIgnoreCase("disabled") &&
tapeAdapter.getCount() < VOCA.this.maxInTape) {
!p.get_status().equalsIgnoreCase("invisible") &&
!p.get_status().equalsIgnoreCase("disabled") &&
tapeAdapter.getCount() < VOCA.this.maxInTape) {
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, //data to be dragged
shadowBuilder, //drag shadow
view, //local data about the drag and drop operation
0 //no needed flags
shadowBuilder, //drag shadow
view, //local data about the drag and drop operation
0 //no needed flags
);
//view.setVisibility(View.INVISIBLE);
}
......@@ -940,11 +940,11 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
public void onClick(View arg0) {
LinkedList<Picto> lp = tapeAdapter.getAll();
// This triggers the "Show" websocket action SI hay algo en la cinta y esta no está vacia
if (lp.size()>0 && !VOCA.this.tapeAdapter.play()) {
if (lp.size() > 0 && !VOCA.this.tapeAdapter.play()) {
PCBcontext.getActionLog().log(new PictosAction(lp));
tapeAdapter.ttsAllNew(tts);
new PictoAnimation().animateTapeView(VOCA.this,0,(ViewGroup)arg0.getParent());
if (PCBcontext.getPcbdb().getCurrentUser().delivery()!= User.JSON_STUDENT_ATTTRS.delivery.clean) {
new PictoAnimation().animateTapeView(VOCA.this, 0, (ViewGroup) arg0.getParent());
if (PCBcontext.getPcbdb().getCurrentUser().delivery() != User.JSON_STUDENT_ATTTRS.delivery.clean) {
showOnlyTape(true);
}
}
......@@ -952,18 +952,17 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
/**
*
* @param onlyTape
*/
protected void showOnlyTape(boolean onlyTape) {
boolean tape_delivered_prev=this.tape_delivered;
Log.e(LOG_TAG,"ONLY TAPE->"+onlyTape+" "+ttsButton.isEnabled());
this.tape_delivered=onlyTape;
boolean tape_delivered_prev = this.tape_delivered;
Log.e(LOG_TAG, "ONLY TAPE->" + onlyTape + " " + ttsButton.isEnabled());
this.tape_delivered = onlyTape;
if (onlyTape) {
if (!tape_delivered_prev) {
if (PCBcontext.getPcbdb().getCurrentUser().delivery()== User.JSON_STUDENT_ATTTRS.delivery.one)
if (PCBcontext.getPcbdb().getCurrentUser().delivery() == User.JSON_STUDENT_ATTTRS.delivery.one)
ttsButton.setEnabled(false);
Log.e(LOG_TAG,"ONLY TAPE0->"+onlyTape+" "+ttsButton.isEnabled());
Log.e(LOG_TAG, "ONLY TAPE0->" + onlyTape + " " + ttsButton.isEnabled());
if (this.pictoMainGridView.getAnimation() != this.hidePictoMainViewAnimation) {
this.showPictoCategoriesViewButton.setVisibility(View.INVISIBLE);
this.pictoCategoryGridView.setVisibility(View.INVISIBLE);
......@@ -977,20 +976,18 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
}
new PictoAnimation().animateTapeViewVertical(this, false);
}
}
else {
} else {
ttsButton.setEnabled(true);
ttsButton.refreshDrawableState();
Log.e(LOG_TAG,"ONLY TAPE1->"+onlyTape+" "+ttsButton.isEnabled());
new PictoAnimation().animateTapeViewVertical(this,true);
Log.e(LOG_TAG, "ONLY TAPE1->" + onlyTape + " " + ttsButton.isEnabled());
new PictoAnimation().animateTapeViewVertical(this, true);
if (this.pictoMainGridView.getAnimation() != this.hidePictoMainViewAnimation) {
this.showPictoCategoriesViewButton.setVisibility(View.VISIBLE);
this.pictoCategoryGridView.setVisibility(View.VISIBLE);
this.pictoMainGridView.setAlpha(1f);
this.pictoMainGridView.setEnabled(true);
this.showPictoCategoriesViewButton.setAlpha(1f);
}
else {
} else {
this.pictoCategoryGridView.setAlpha(1f);
this.pictoCategoryGridView.setEnabled(true);
this.showPictoCategoriesViewButton.setAlpha(1f);
......@@ -1014,7 +1011,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
PCBcontext.getActionLog().log(new TalkAction(TalkAction.DELETE, p));
// Send websocket action
Picto last=tapeAdapter.deleteLastView();
Picto last = tapeAdapter.deleteLastView();
tapeAdapter.notifyDataSetChanged();
if (pictoMainGridAdapter.pictoInThisCategory(last))
pictoMainGridAdapter.pictoInGrid(last);
......@@ -1080,7 +1077,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
pictoCategoryGridAdapter.notifyDataSetInvalidated();
pictoMainGridAdapter.notifyDataSetInvalidated();
VOCA.this.finish();
if (SessionActivity.session!=null) SessionActivity.session.finish();
if (SessionActivity.session != null) SessionActivity.session.finish();
PCBcontext.getNetService().restart_app(true);
}
return true;
......@@ -1100,11 +1097,11 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
int in=0,out=0;
int in = 0, out = 0;
Intent nextActivity = null;
Intent intent = getIntent();
if ( PCBcontext.getPcbdb() != null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ) {
if (PCBcontext.getPcbdb() != null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor()) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
......@@ -1124,7 +1121,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
in = R.anim.leftin;
out = R.anim.leftout;
if (nextActivity != null) {
tape_delivered=false;
tape_delivered = false;
finish();
startActivity(nextActivity);
overridePendingTransition(in, out);
......
......@@ -112,9 +112,9 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
protected boolean deleting;
protected boolean tape_delivered=false;
protected boolean tape_delivered = false;
float firstTouchX = -1;
public boolean inserting=false;
public boolean inserting = false;
@TargetApi(Build.VERSION_CODES.M)
@Override
......@@ -126,7 +126,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
// after a long inactivity, the pcbdb is discarded
if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"PCBDB was discarded. App restarting");
Log.i(LOG_TAG, "PCBDB was discarded. App restarting");
NetServiceTablet.restart_PictogramTablet(this);
return;
}
......@@ -147,28 +147,28 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
@Override
public void action(action action, int picto_cat, int picto_id, JSONObject msg) {
Log.i(this.getClass().getCanonicalName(), action + " from " + picto_cat + "," + picto_id + " catched");
if (action==ActionTalk.iActionListener.action.show) {
if (action == ActionTalk.iActionListener.action.show) {
Log.i("TAG_PRUEBAS","show message received:"+msg.toString());
Log.i("TAG_PRUEBAS", "show message received:" + msg.toString());
JSONObject msg_attrs = null;
JSONArray pictos = null;
String mensaje= "";
String mensaje = "";
try {
msg_attrs = msg.getJSONObject("attributes");
pictos = msg_attrs.getJSONArray("pictos");
String user = pictos.getJSONObject(0).getJSONObject("attributes").getString("user_avatar");
if(user.equals(PCBcontext.getPcbdb().getCurrentUser().get_email_sup())){ //si el primer picto tiene ese sup asociado
mensaje += getResources().getString(R.string.message_from)+": "+PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+", "+ PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+"\n";
mensaje += getResources().getString(R.string.says)+": ";
for(int i = 0; i < pictos.length(); i++) {
if (user.equals(PCBcontext.getPcbdb().getCurrentUser().get_email_sup())) { //si el primer picto tiene ese sup asociado
mensaje += getResources().getString(R.string.message_from) + ": " + PCBcontext.getPcbdb().getCurrentUser().get_name_stu() + ", " + PCBcontext.getPcbdb().getCurrentUser().get_surname_stu() + "\n";
mensaje += getResources().getString(R.string.says) + ": ";
for (int i = 0; i < pictos.length(); i++) {
JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes");
mensaje += (i != pictos.length()-1 ? picto.get("expression").toString()+" - " : picto.get("expression").toString());
mensaje += (i != pictos.length() - 1 ? picto.get("expression").toString() + " - " : picto.get("expression").toString());
}
Log.i(LOG_TAG,"Mensaje: "+msg.toString());
Log.i(LOG_TAG, "Mensaje: " + msg.toString());
final AlertDialog.Builder builder = new AlertDialog.Builder(VocabularyManager.this);
builder.setMessage(mensaje)
.setPositiveButton("Vale", new DialogInterface.OnClickListener() {
......@@ -191,9 +191,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
}
else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
} else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
Picto picto = vocabulary.get_picto(picto_cat, picto_id);
VocabularyManager.this.execHighligthFeeback(picto, true);
}
......@@ -263,7 +261,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
try {
StudentPhotoView.setImageBitmap(student.get_bitmap_stu(this.getBaseContext()));
} catch (IOException e) {
Log.e(LOG_TAG,e.getMessage());
Log.e(LOG_TAG, e.getMessage());
}
......@@ -275,10 +273,10 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
onWindowFocusChanged(true);
Log.i(LOG_TAG, "Resuming Pictogram Activity");
PCBcontext.setActivityContext(this);
Toast.makeText(this.getBaseContext(), PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+
Toast.makeText(this.getBaseContext(), PCBcontext.getPcbdb().getCurrentUser().get_name_stu() + " " + PCBcontext.getPcbdb().getCurrentUser().get_surname_stu() +
(PCBcontext.getPcbdb().getCurrentUser().is_supervisor()
? " ("+ PCBcontext.getPcbdb().getCurrentUser().get_name_sup()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_sup()+")"
:"")
? " (" + PCBcontext.getPcbdb().getCurrentUser().get_name_sup() + " " + PCBcontext.getPcbdb().getCurrentUser().get_surname_sup() + ")"
: "")
, Toast.LENGTH_SHORT).show();
}
......@@ -342,6 +340,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
this.pictoCategoryGridAdapter.allPictosInGrid();
this.pictoMainGridAdapter.allPictosInGrid();
}
@Override
protected void onStop() {
super.onStop();
......@@ -468,9 +467,9 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
// This is to show the pictos ordered in the 2D Array that represents the panel
Picto[][] mp = new Picto[maxRows][maxColumns];
Iterator<Picto> pictos=list.iterator();
Iterator<Picto> pictos = list.iterator();
while (pictos.hasNext()) {
Picto p= pictos.next();
Picto p = pictos.next();
if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().has_categories()) {
if (p.get_column() != -1 && p.get_row() != -1
&& p.get_column() < maxRows && p.get_row() < maxColumns) {
......@@ -654,7 +653,6 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
/**
*
* @return
*/
public Picto getCurrentCategory() {
......@@ -666,7 +664,8 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
* Event listener classes
* ********************************************************************************************/
/**f
/**
* f
* Class used for picto clicking feedback
*/
private class OnPictoClickListener implements AdapterView.OnItemClickListener {
......@@ -690,7 +689,6 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
/**
*
* @param picto
* @param highlight_background
*/
......@@ -713,6 +711,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
prev_picto = picto;
exec_mirror.scheduleAtFixedRate(new Runnable() {
int repeating = 0;
@Override
public void run() {
refresh();
......@@ -729,6 +728,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
// TODO: REVISAR
/**
* Class used for long pressing on pictos (pictomenu)
*/
......@@ -746,7 +746,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
} else {
//Si es supervisor hacer aparecer el menú de opciones del picto
new PictoMenu(VocabularyManager.this).createMenuForPicto(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big(),p);
new PictoMenu(VocabularyManager.this).createMenuForPicto(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big(), p);
getCurrentPictoGridAdapter().notifyDataSetChanged();
}
return true;
......@@ -766,11 +766,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
int in=0,out=0;
int in = 0, out = 0;
Intent nextActivity = null;
Intent intent = getIntent();
if ( PCBcontext.getPcbdb() != null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ) {
if (PCBcontext.getPcbdb() != null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor()) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
......@@ -782,8 +782,8 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
// Pasa de VocabularyManager a voca
nextActivity = new Intent(this, VOCA.class);
in=R.anim.rightin;
out=R.anim.rightout;
in = R.anim.rightin;
out = R.anim.rightout;
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
......@@ -798,7 +798,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
}
if (nextActivity != null) {
tape_delivered=false;
tape_delivered = false;
finish();
startActivity(nextActivity);
overridePendingTransition(in, out);
......@@ -813,6 +813,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
/**
* Para capturar el evento para abrir camara o galeria y procesar
*
* @param requestCode
* @param resultCode
* @param data
......@@ -821,47 +822,47 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
super.onActivityResult(requestCode, resultCode, data);
Bitmap imagen;
switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode==RESULT_OK) {
imagen = (Bitmap) data.getExtras().get("data");
this.launchEditPictoActivity(imagen);
}
break;
case GALLERY_PIC_REQUEST: //Galeria
if(data!=null){
Uri selectedImage = data.getData();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
} catch (IOException e) {
e.printStackTrace();
}
this.launchEditPictoActivity(bitmap);
}
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK) {
boolean edit = data.getBooleanExtra(PictoMenu.IS_EDIT,false);
int row = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
String path_sound = data.getExtras().getString(PictoMenu.PATH_SOUND);
String user_avatar = data.getExtras().getString(Picto.JSON_ATTTRS.USER_AVATAR);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(PictoMenu.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, path_sound ,user_avatar);
refresh();
}
break;
}
switch (requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode == RESULT_OK) {
imagen = (Bitmap) data.getExtras().get("data");
this.launchEditPictoActivity(imagen);
}
break;
case GALLERY_PIC_REQUEST: //Galeria
if (data != null) {
Uri selectedImage = data.getData();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
} catch (IOException e) {
e.printStackTrace();
}
this.launchEditPictoActivity(bitmap);
}
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK) {
boolean edit = data.getBooleanExtra(PictoMenu.IS_EDIT, false);
int row = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
String path_sound = data.getExtras().getString(PictoMenu.PATH_SOUND);
String user_avatar = data.getExtras().getString(Picto.JSON_ATTTRS.USER_AVATAR);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(PictoMenu.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, path_sound, user_avatar);
refresh();
}
break;
}
}
......@@ -869,37 +870,39 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
* función para la edición de un texto asociado a una nueva imagen y guardar el nuevo picto
*/
public void chooseTextAndSavePicto(final String selectedImagePath, final int row, final int col, final int freeRow, final int freeColumn,
final int category, final String legend,final String path_sound ,final String user_avatar) {
final int category, final String legend, final String path_sound, final String user_avatar) {
// Set up the buttons
PCBcontext.getVocabulary().saveLocalPicto(
selectedImagePath,
legend,
category,
row,
col,
freeRow,
freeColumn,
user_avatar,
path_sound,
new iLocalPicto() {
@Override
public void saved(Picto localPicto) {
refresh();
try {
if (PCBcontext.is_user_online())
new PictoUploader(localPicto).upload();
} catch (IOException e) {
Log.e(Vocabulary.class.getCanonicalName(), e.getMessage());
selectedImagePath,
legend,
category,
row,
col,
freeRow,
freeColumn,
user_avatar,
path_sound,
new iLocalPicto() {
@Override
public void saved(Picto localPicto) {
refresh();
try {
if (PCBcontext.is_user_online())
new PictoUploader(localPicto).upload();
} catch (IOException e) {
Log.e(Vocabulary.class.getCanonicalName(), e.getMessage());
}
}
}
});
});
}
/**Para cambiar la activity de voca a EditPictoActivity
/**
* Para cambiar la activity de voca a EditPictoActivity
*
* @param image
*/
public void launchEditPictoActivity(Bitmap image){
public void launchEditPictoActivity(Bitmap image) {
Intent intent = new Intent(this, EditPictoActivity.class);
BitmapTools.save_temporal(image);
......
......@@ -26,7 +26,7 @@ import java.util.Vector;
* LoginActivity show the login window to select the student and supervisor
* It uses device to read the token value
*/
public class LoginActivity extends FragmentActivity {
public class LoginActivity extends FragmentActivity {
// String constant for logs
......@@ -34,30 +34,31 @@ public class LoginActivity extends FragmentActivity {
/**
* If there is Internet connection it calls the WS to recover the pairs student-supervisor
*
* @param savedInstanceState
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
onWindowFocusChanged(true);
requestWindowFeature(Window.FEATURE_NO_TITLE);
onWindowFocusChanged(true);
setContentView(com.yottacode.pictogram.tabletlibrary.R.layout.activity_login);
setContentView(com.yottacode.pictogram.tabletlibrary.R.layout.activity_login);
// Enable logout button
// Enable logout button
final Button logoutButton = (Button) findViewById(R.id.loginTopbarLogout);
logoutButton.setEnabled(true);
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent serialActivity = new Intent(getBaseContext(), com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", true);
startActivity(serialActivity);
}
});
final Button logoutButton = (Button) findViewById(R.id.loginTopbarLogout);
logoutButton.setEnabled(true);
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent serialActivity = new Intent(getBaseContext(), com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", true);
startActivity(serialActivity);
}
});
}
@Override
......@@ -69,7 +70,7 @@ public class LoginActivity extends FragmentActivity {
supervisorFullNameView.setText(
this.getIntent().getStringExtra("name") + " " +
this.getIntent().getStringExtra("surname") + " ("+this.getIntent().getStringExtra("email")+")");
this.getIntent().getStringExtra("surname") + " (" + this.getIntent().getStringExtra("email") + ")");
final Vector<Img> imgs = new Vector<>(1);
imgs.add(new Img(
......@@ -81,7 +82,7 @@ public class LoginActivity extends FragmentActivity {
@Override
public void loadComplete() {
try {
supervisorPhotoView.setImageBitmap(
supervisorPhotoView.setImageBitmap(
imgs.get(0).get_bitmap(PCBcontext.getContext())
);
supervisorPhotoView.invalidate();
......@@ -91,22 +92,25 @@ public class LoginActivity extends FragmentActivity {
}
@Override
public void loadImg(Img image) {}
@Override
public void error(Exception e) {
GUITools.show_alert(PCBcontext.getContext(), R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage());
}
public void loadImg(Img image) {
}
@Override
public void error(Exception e) {
GUITools.show_alert(PCBcontext.getContext(), R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:" + e.getLocalizedMessage());
}
}, ImgDownloader.tsource.remote);
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG,"Closing Login window");
PCBcontext.getNetService().closeNotifyStatus();
}
@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG, "Closing Login window");
PCBcontext.getNetService().closeNotifyStatus();
}
@Override
public void onResume() {
super.onResume();
......
......@@ -34,30 +34,30 @@ import java.util.Hashtable;
public class SessionActivity extends FragmentActivity implements ListInstructionsFragment.iListInstructionsFragment, SessionFragment.iSessionFragment {
private static final String FRAGMENT_SESSION="session";
private static final String FRAGMENT_METHOD="method";
private static final String FRAGMENT_SESSION = "session";
private static final String FRAGMENT_METHOD = "method";
private static final String LOG_TAG = SessionActivity.class.getCanonicalName();
public static FragmentActivity session=null;
public static FragmentActivity session = null;
private int currentInstruction;
private int id_session;
private Hashtable<Integer,Integer> msgs=new Hashtable<>(20);
private Hashtable<Integer, Integer> msgs = new Hashtable<>(20);
private NetService.iNetServiceStatus listenerStatus;
float firstTouchX=-1;
float firstTouchX = -1;
ListInstructionsFragment listInstructionsFragment= new ListInstructionsFragment();
ListInstructionsFragment listInstructionsFragment = new ListInstructionsFragment();
private void addLogMsg(final String msg) {
private void addLogMsg(final String msg) {
runOnUiThread(new Runnable() {
public void run() {
ListView log=(ListView) findViewById(R.id.session_serverlog);
ArrayAdapter adapter = (ArrayAdapter) log.getAdapter();
adapter.add(new java.text.SimpleDateFormat("HH:mm:ss").format(new Date())+": "+msg+'\n');
}
});
runOnUiThread(new Runnable() {
public void run() {
ListView log = (ListView) findViewById(R.id.session_serverlog);
ArrayAdapter adapter = (ArrayAdapter) log.getAdapter();
adapter.add(new java.text.SimpleDateFormat("HH:mm:ss").format(new Date()) + ": " + msg + '\n');
}
});
}
......@@ -68,24 +68,24 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public void play_msg() {
evaluateMsg(this.msgs.size()-1, null, R.string.session_eval_notevuated,R.drawable.session_notevaluated);
evaluateMsg(this.msgs.size() - 1, null, R.string.session_eval_notevuated, R.drawable.session_notevaluated);
}
private void evaluateMsg(final int msg_pos, final String evaluation_value, final int evaluation_translation, final int evaluation_bitmap) {
final SessionFragment sessionFragment = (SessionFragment) getSupportFragmentManager().findFragmentByTag(SessionActivity.FRAGMENT_SESSION);
final int currentMsgId=SessionActivity.this.msgs.get(msg_pos);
if (sessionFragment.get_current_msg_text().trim().length()>0) //no se permiten trys vacios
SessionWrapper.evaluateTry(currentMsgId, msg_pos==this.msgs.size()-1, evaluation_value, new SessionWrapper.iTryUpdated() {
final int currentMsgId = SessionActivity.this.msgs.get(msg_pos);
if (sessionFragment.get_current_msg_text().trim().length() > 0) //no se permiten trys vacios
SessionWrapper.evaluateTry(currentMsgId, msg_pos == this.msgs.size() - 1, evaluation_value, new SessionWrapper.iTryUpdated() {
@Override
public void update(int next_try_id) {
addLogMsg("añadiendo "+ sessionFragment.get_current_msg_text()+".");
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),evaluation_bitmap);
sessionFragment.evaluateMsg(bitmap,getString(evaluation_translation),msg_pos);
addLogMsg("#"+(msg_pos<9 ? "0" : "")+(msg_pos+1)+sessionFragment.get_msg_text(msg_pos));
addLogMsg("añadiendo " + sessionFragment.get_current_msg_text() + ".");
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), evaluation_bitmap);
sessionFragment.evaluateMsg(bitmap, getString(evaluation_translation), msg_pos);
addLogMsg("#" + (msg_pos < 9 ? "0" : "") + (msg_pos + 1) + sessionFragment.get_msg_text(msg_pos));
if (!msgs.containsValue(next_try_id))
new_try(sessionFragment, next_try_id);
if (evaluation_value!=null && msg_pos==msgs.size()-1){
if (evaluation_value != null && msg_pos == msgs.size() - 1) {
SessionWrapper.newTry(id_session, new SessionWrapper.iTryUpdated() {
@Override
public void update(int id) {
......@@ -104,18 +104,17 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public void error(String error) {
addLogMsg(getString(R.string.session_error)+":"+error);
Log.e(LOG_TAG,"server error:"+error+" when updating try "+currentMsgId+" to "+evaluation_value);
addLogMsg(getString(R.string.session_error) + ":" + error);
Log.e(LOG_TAG, "server error:" + error + " when updating try " + currentMsgId + " to " + evaluation_value);
}
});
}
private void new_try(SessionFragment sessionFragment, int next_try_id) {
int pos_newmsg=sessionFragment.newMsg();
msgs.put(pos_newmsg,next_try_id);
int pos_newmsg = sessionFragment.newMsg();
msgs.put(pos_newmsg, next_try_id);
addLogMsg(getString(R.string.session_log_newtry));
}
......@@ -143,7 +142,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
final int msg_pos = sessionFragment.get_current_msg_pos();
evaluateMsg(msg_pos, value, translation, button);
if (msg_pos != sessionFragment.get_last_msg_pos())
sessionFragment.adapter_pictomsg.setCurrentMsg(sessionFragment.adapter_pictomsg.getCount()-1);
sessionFragment.adapter_pictomsg.setCurrentMsg(sessionFragment.adapter_pictomsg.getCount() - 1);
}
return true;
......@@ -151,47 +150,45 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SessionActivity.session=this;
SessionActivity.session = this;
requestWindowFeature(Window.FEATURE_NO_TITLE);
onWindowFocusChanged(true);
setContentView(R.layout.activity_session);
User student=PCBcontext.getPcbdb().getCurrentUser();
User student = PCBcontext.getPcbdb().getCurrentUser();
final TextView StudentFullNameView = (TextView) findViewById(R.id.sessionTopbarStudentFullName);
final ImageView StudentPhotoView = (ImageView) findViewById(R.id.sessionTopbarStudentPhoto);
final ToggleButton onoffBtn=((ToggleButton)findViewById(R.id.sessionOnOffBtn));
final ToggleButton pauseBtn=((ToggleButton)findViewById(R.id.sessionPauseBtn));
final Button okBtn =((Button)findViewById(R.id.btn_correct));
final Button disBtn =((Button)findViewById(R.id.btn_discarded));
final Button spoBtn =((Button)findViewById(R.id.btn_spontaneous));
final Button failBtn =((Button)findViewById(R.id.btn_fail));
final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model));
final ToggleButton onoffBtn = ((ToggleButton) findViewById(R.id.sessionOnOffBtn));
final ToggleButton pauseBtn = ((ToggleButton) findViewById(R.id.sessionPauseBtn));
final Button okBtn = ((Button) findViewById(R.id.btn_correct));
final Button disBtn = ((Button) findViewById(R.id.btn_discarded));
final Button spoBtn = ((Button) findViewById(R.id.btn_spontaneous));
final Button failBtn = ((Button) findViewById(R.id.btn_fail));
final Button supBtn = ((Button) findViewById(R.id.btn_supervised));
final Button modBtn = ((Button) findViewById(R.id.btn_model));
((ListView) findViewById(R.id.session_serverlog)).setAdapter(new ArrayAdapter<String>(getBaseContext(), R.layout.list_logsessions));
StudentFullNameView.setText(student.get_name_stu() + " " + student.get_surname_stu());
try {
StudentPhotoView.setImageBitmap(student.get_bitmap_stu(this.getBaseContext()));
} catch (IOException e) {
Log.e(LOG_TAG,e.getMessage());
Log.e(LOG_TAG, e.getMessage());
}
okBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_ok,"SUCCESS",R.string.session_eval_success));
failBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_fail,"FAIL",R.string.session_eval_fail));
spoBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_spontaneous,"SPONTANEOUS SUCCESS",R.string.session_eval_spontaneous));
supBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_supervised,"SUPERVISED SUCCESS",R.string.session_eval_supervised));
modBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_model,"MODEL", R.string.session_eval_model));
disBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_discarded,"DISCARDED", R.string.session_eval_discarded));
okBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_ok, "SUCCESS", R.string.session_eval_success));
failBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_fail, "FAIL", R.string.session_eval_fail));
spoBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_spontaneous, "SPONTANEOUS SUCCESS", R.string.session_eval_spontaneous));
supBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_supervised, "SUPERVISED SUCCESS", R.string.session_eval_supervised));
modBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_model, "MODEL", R.string.session_eval_model));
disBtn.setOnTouchListener(new TouchButtonListener(R.drawable.session_discarded, "DISCARDED", R.string.session_eval_discarded));
onoffBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
set_fragment(isChecked,onoffBtn);
set_fragment(isChecked, onoffBtn);
}
});
onoffBtn.setEnabled(false);
......@@ -208,7 +205,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public void error(String error) {
GUITools.show_alert(SessionActivity.this, R.string.session_pause_error,"error "+error);
GUITools.show_alert(SessionActivity.this, R.string.session_pause_error, "error " + error);
}
});
}
......@@ -219,23 +216,23 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
protected void onStart() {
super.onStart();
if (((ToggleButton)findViewById(R.id.sessionOnOffBtn)).isChecked())
set_fragment_sesion();
else set_fragment_method();
if (((ToggleButton) findViewById(R.id.sessionOnOffBtn)).isChecked())
set_fragment_sesion();
else set_fragment_method();
this.listenerStatus = new NetService.iNetServiceStatus() {
boolean m_updated=true;
boolean m_updated = true;
@Override
public void notifyStatus(final boolean updated) {
runOnUiThread(new Runnable() {
public void run() {
if (!updated && m_updated) {
m_updated=false;
m_updated = false;
GUITools.show_alert(SessionActivity.this, R.string.session_noinet);
addLogMsg(getString(R.string.session_noinet));
} else
if (updated && !m_updated) {
m_updated=true;
} else if (updated && !m_updated) {
m_updated = true;
GUITools.show_alert(SessionActivity.this, R.string.session_inetok);
addLogMsg(getString(R.string.session_inetok));
}
......@@ -255,60 +252,60 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public void instruction_selected(int instruction, String instruction_name) {
addLogMsg(instruction_name);
this.currentInstruction=instruction;
((TextView)findViewById(R.id.sessionTopbarInstructionName)).setText(instruction_name);
this.currentInstruction = instruction;
((TextView) findViewById(R.id.sessionTopbarInstructionName)).setText(instruction_name);
findViewById(R.id.sessionOnOffBtn).setEnabled(true);
}
@Override
public void method_selected(int method, String method_name) {
((ToggleButton)findViewById(R.id.sessionOnOffBtn)).setEnabled(false);
((TextView)findViewById(R.id.sessionTopbarMethodName)).setText(method_name);
((ToggleButton) findViewById(R.id.sessionOnOffBtn)).setEnabled(false);
((TextView) findViewById(R.id.sessionTopbarMethodName)).setText(method_name);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
int in=0,out=0;
Intent nextActivity=null;
int in = 0, out = 0;
Intent nextActivity = null;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
firstTouchX = event.getX();
break;
case MotionEvent.ACTION_UP:
if (event.getX()> firstTouchX+100) { //izquierda->derecha
// Pasa de SessionActivity a Vocabulary Manager
nextActivity=new Intent(this,VocabularyManager.class);
in=R.anim.rightin;
out=R.anim.rightout;
}
else if (firstTouchX > event.getX()+100) { //derecha->izquierda
case MotionEvent.ACTION_DOWN:
firstTouchX = event.getX();
break;
case MotionEvent.ACTION_UP:
if (event.getX() > firstTouchX + 100) { //izquierda->derecha
// Pasa de SessionActivity a Vocabulary Manager
nextActivity = new Intent(this, VocabularyManager.class);
in = R.anim.rightin;
out = R.anim.rightout;
} else if (firstTouchX > event.getX() + 100) { //derecha->izquierda
// No action
// No action
}
if (nextActivity!=null) {
startActivity(nextActivity);
overridePendingTransition(in, out);
}
break;
}
if (nextActivity != null) {
startActivity(nextActivity);
overridePendingTransition(in, out);
}
break;
}
return super.dispatchTouchEvent(event);
}
private SessionFragment set_fragment_sesion() {
final Button okBtn =((Button)findViewById(R.id.btn_correct));
final Button disBtn =((Button)findViewById(R.id.btn_discarded));
final Button spoBtn =((Button)findViewById(R.id.btn_spontaneous));
final Button failBtn =((Button)findViewById(R.id.btn_fail));
final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model));
private SessionFragment set_fragment_sesion() {
final Button okBtn = ((Button) findViewById(R.id.btn_correct));
final Button disBtn = ((Button) findViewById(R.id.btn_discarded));
final Button spoBtn = ((Button) findViewById(R.id.btn_spontaneous));
final Button failBtn = ((Button) findViewById(R.id.btn_fail));
final Button supBtn = ((Button) findViewById(R.id.btn_supervised));
final Button modBtn = ((Button) findViewById(R.id.btn_model));
SessionFragment sessionFragment = (SessionFragment) getSupportFragmentManager().findFragmentByTag(SessionActivity.FRAGMENT_SESSION);
if (sessionFragment==null) sessionFragment=new SessionFragment();
if (sessionFragment == null) sessionFragment = new SessionFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.sessions_fragment_container, sessionFragment, SessionActivity.FRAGMENT_SESSION)
.commitNow()
.beginTransaction()
.replace(R.id.sessions_fragment_container, sessionFragment, SessionActivity.FRAGMENT_SESSION)
.commitNow()
;
findViewById(R.id.sessionPauseBtn).setVisibility(View.VISIBLE);
okBtn.setVisibility(View.VISIBLE);
......@@ -321,18 +318,19 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
findViewById(R.id.sessionTopbarInstructionName).setVisibility(View.VISIBLE);
return sessionFragment;
}
private void set_fragment_method() {
final Button okBtn =((Button)findViewById(R.id.btn_correct));
final Button disBtn =((Button)findViewById(R.id.btn_discarded));
final Button spoBtn =((Button)findViewById(R.id.btn_spontaneous));
final Button failBtn =((Button)findViewById(R.id.btn_fail));
final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model));
final Button okBtn = ((Button) findViewById(R.id.btn_correct));
final Button disBtn = ((Button) findViewById(R.id.btn_discarded));
final Button spoBtn = ((Button) findViewById(R.id.btn_spontaneous));
final Button failBtn = ((Button) findViewById(R.id.btn_fail));
final Button supBtn = ((Button) findViewById(R.id.btn_supervised));
final Button modBtn = ((Button) findViewById(R.id.btn_model));
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.sessions_fragment_container, listInstructionsFragment, SessionActivity.FRAGMENT_METHOD)
.commit()
.beginTransaction()
.replace(R.id.sessions_fragment_container, listInstructionsFragment, SessionActivity.FRAGMENT_METHOD)
.commit()
;
findViewById(R.id.sessionPauseBtn).setVisibility(View.INVISIBLE);
okBtn.setVisibility(View.INVISIBLE);
......@@ -344,10 +342,12 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
findViewById(R.id.sessionTopbarMethodName).setVisibility(View.INVISIBLE);
findViewById(R.id.sessionTopbarInstructionName).setVisibility(View.INVISIBLE);
}
void close() {
finish();
startActivity(new Intent(SessionActivity.this, VOCA.class));
}
private void set_fragment(boolean isChecked, final ToggleButton onoffBtn) {
if (isChecked) {
......@@ -355,11 +355,11 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
SessionWrapper.startSession(this.currentInstruction, new SessionWrapper.iStartSession() {
@Override
public void started(int id_session, int id_first_try) {
addLogMsg(getString(R.string.session_log_startsession));
SessionActivity.this.id_session = id_session;
SessionFragment session= set_fragment_sesion();
onoffBtn.setText("STOP");
new_try(session, id_first_try);
addLogMsg(getString(R.string.session_log_startsession));
SessionActivity.this.id_session = id_session;
SessionFragment session = set_fragment_sesion();
onoffBtn.setText("STOP");
new_try(session, id_first_try);
}
@Override
......@@ -430,6 +430,6 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public void onDestroy() {
super.onDestroy();
SessionActivity.session=null;
SessionActivity.session = null;
}
}
......@@ -14,7 +14,6 @@
android:layout_height="match_parent">
<!-- android:keepScreenOn - To keep the screen bright as long as the app is visible (also forever) -->
<ImageButton
android:id="@+id/button_delete"
android:layout_width="@dimen/tape_normal_height"
......
......@@ -14,7 +14,6 @@
android:layout_height="match_parent">
<!-- android:keepScreenOn - To keep the screen bright as long as the app is visible (also forever) -->
<ImageButton
android:id="@+id/button_delete"
android:layout_width="@dimen/tape_big_height"
......
......@@ -86,12 +86,12 @@
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/vmTopbarLayout"
android:background="#DDDDDD"
android:gravity="center_vertical|center|center_horizontal"
android:horizontalSpacing="@dimen/picto_grid_spacing"
android:paddingLeft="@dimen/small_padding"
android:verticalSpacing="@dimen/picto_grid_spacing"
android:layout_below="@+id/vmTopbarLayout"></GridView>
android:verticalSpacing="@dimen/picto_grid_spacing"></GridView>
</RelativeLayout>
......
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