auto indent files

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