Varios bugs solucionados

parent 6383f43e
...@@ -51,6 +51,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener, ...@@ -51,6 +51,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
private static final String TAG_PIC = "pic"; private static final String TAG_PIC = "pic";
private static final String TAG_LANG = "lang"; private static final String TAG_LANG = "lang";
private static final String TAG_ATTRIBUTES = "attributes"; private static final String TAG_ATTRIBUTES = "attributes";
private static final String TAG_SUPERVISION = "supervision";
private int sup_id; private int sup_id;
...@@ -153,6 +154,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener, ...@@ -153,6 +154,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
public void result(JSONArray students_supervisors) { //FERNANDO public void result(JSONArray students_supervisors) { //FERNANDO
try { try {
// Saco los pares estudiante-supervisor // Saco los pares estudiante-supervisor
//Log.d(LOG_TAG, "JSON:"+students_supervisors);
Log.d(LOG_TAG, "students_supervisors size:" + students_supervisors.length()); Log.d(LOG_TAG, "students_supervisors size:" + students_supervisors.length());
// looping through All Students // looping through All Students
Vector<User> users = new Vector<User>(students_supervisors.length()); Vector<User> users = new Vector<User>(students_supervisors.length());
...@@ -189,14 +191,18 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener, ...@@ -189,14 +191,18 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
String st_lang = st.getString(TAG_LANG); String st_lang = st.getString(TAG_LANG);
//st_lang = "es-es"; //st_lang = "es-es";
String st_attributes = st.getString(TAG_ATTRIBUTES); String st_attributes = st.getString(TAG_ATTRIBUTES);
Integer st_supervision = st.getInt(TAG_SUPERVISION);
//Log.d(LOG_TAG, "student pic:" + st_pic); //Log.d(LOG_TAG, "student pic:" + st_pic);
// Añado un par <student-supervisor> // Añado un par <student-supervisor>
int st_id_int = st_id.intValue(); int st_id_int = st_id.intValue();
student = new User(st_id_int, st_name, st_surname, st_pic, st_gender, st_lang, st_attributes, int st_supervision_int = st_supervision.intValue();
sup_id, "", "", "", "M", "es-es", ""); if (st_supervision_int==2){
users.add(student); student = new User(st_id_int, st_name, st_surname, st_pic, st_gender, st_lang, st_attributes,
sup_id, "", "", "", "M", "es-es", "");
users.add(student);
}
} }
// Si sólo hay 1 estudiante, cargo el st_id // Si sólo hay 1 estudiante, cargo el st_id
......
...@@ -15,11 +15,16 @@ import android.widget.Toast; ...@@ -15,11 +15,16 @@ import android.widget.Toast;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.dao.Device; import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.PCBDBHelper; import com.yottacode.pictogram.dao.PCBDBHelper;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Vector;
public class MainActivity extends Activity { public class MainActivity extends Activity {
...@@ -35,28 +40,13 @@ public class MainActivity extends Activity { ...@@ -35,28 +40,13 @@ public class MainActivity extends Activity {
// For deactivating the lock screen (just before setContentView) // For deactivating the lock screen (just before setContentView)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
// Singleton getInstance and initialization passing the Context (to create the device)
//PCBcontext pcb = PCBcontext.getInstance();
PCBcontext.init(this); PCBcontext.init(this);
Log.d(LOG_TAG, "PCBcontext iniciado"); Log.d(LOG_TAG, "PCBcontext iniciado.");
// Nota magc: al pasar ya siempre por serial no tiene sentido tener main ¿no?
//if (1==0){ // Fuerzo a que entre en serialActivity
Intent serialActivity = new Intent(this, SerialActivity.class); Intent serialActivity = new Intent(this, SerialActivity.class);
startActivity(serialActivity); startActivity(serialActivity);
/*
if (token==null || token.isEmpty()){
Intent serialActivity = new Intent(this, SerialActivity.class);
startActivity(serialActivity);
} else{
Log.d(LOG_TAG, "token leido:" + token);
Intent loginActivity = new Intent(this, LoginActivity.class);
startActivity(loginActivity);
Intent pictogramActivity = new Intent(this, PictogramActivity.class);
startActivity(pictogramActivity);
}
*/
} }
@Override @Override
......
...@@ -19,6 +19,7 @@ import android.util.Log; ...@@ -19,6 +19,7 @@ import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.DragEvent; import android.view.DragEvent;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
...@@ -78,6 +79,12 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -78,6 +79,12 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
// String constant for logs // String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName() private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
float xAxis = 0f;
float yAxis = 0f;
float lastXAxis = 0f;
float lastYAxis = 0f;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -130,6 +137,43 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -130,6 +137,43 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
tapeGridView.getLayoutParams().width = width - 120; tapeGridView.getLayoutParams().width = width - 120;
tapeGridView.requestLayout(); tapeGridView.requestLayout();
tapeGridView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int actionPeformed = event.getAction();
switch (actionPeformed) {
case MotionEvent.ACTION_DOWN: {
final float x = event.getX();
final float y = event.getY();
lastXAxis = x;
lastYAxis = y;
Log.d(LOG_TAG, "TOUCH X:" + Float.toString(lastXAxis));
Log.d(LOG_TAG, "TOUCH Y:" + Float.toString(lastYAxis));
break;
}
case MotionEvent.ACTION_MOVE: {
final float x = event.getX();
final float y = event.getY();
final float dx = x - lastXAxis;
final float dy = y - lastYAxis;
xAxis += dx;
yAxis += dy;
Log.d(LOG_TAG, "MOVE X:" + Float.toString(xAxis));
Log.d(LOG_TAG, "MOVE Y:" + Float.toString(yAxis));
break;
}
}
return true;
}
});
final GridView panelGridView = (GridView) findViewById(R.id.panel_grid_view); final GridView panelGridView = (GridView) findViewById(R.id.panel_grid_view);
final ImageButton deleteButton = (ImageButton) findViewById(R.id.button_delete); final ImageButton deleteButton = (ImageButton) findViewById(R.id.button_delete);
//final Button deleteAllButton = (Button) findViewById(R.id.button_delete_all); //final Button deleteAllButton = (Button) findViewById(R.id.button_delete_all);
...@@ -167,64 +211,66 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -167,64 +211,66 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
//rowNumberAdapter.notifyDataSetChanged(); //rowNumberAdapter.notifyDataSetChanged();
Picto p = panelAdapter.getItem(position); Picto p = panelAdapter.getItem(position);
Log.d(LOG_TAG, "Clic en picto: " + p.toString()); if (p!=null && !p.is_invisible() && p.is_enabled()){
//Log.d(LOG_TAG, "STATUS: " + p.get_status()); Log.d(LOG_TAG, "Clic en picto: " + p.toString());
//Log.d(LOG_TAG, "STATUS: " + p.get_status());
//QUITAR PARA QUE HABLE panelAdapter.ttsPicto(p, tts); //QUITAR PARA QUE HABLE panelAdapter.ttsPicto(p, tts);
// 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")) {
LinkedList<Picto> ll = order(vocabulary.next(p)); LinkedList<Picto> ll = order(vocabulary.next(p));
//LinkedList<Picto> ll = vocabulary.next(p); //LinkedList<Picto> ll = vocabulary.next(p);
Log.d(LOG_TAG, "Lista de pictos recuperada: " + ll.toString()); Log.d(LOG_TAG, "Lista de pictos recuperada: " + ll.toString());
int maxInTape= getResources().getInteger(R.integer.maxInTape); int maxInTape= getResources().getInteger(R.integer.maxInTape);
// If the picto is a category // If the picto is a category
if (p.is_category()) { if (p.is_category()) {
panelAdapter.clear(); panelAdapter.clear();
//if (panelAdapter.isEmpty()) //if (panelAdapter.isEmpty())
// Log.d(LOG_TAG, "EMPTY !!!!"); // Log.d(LOG_TAG, "EMPTY !!!!");
//panelAdapter.deleteAll(); //panelAdapter.deleteAll();
panelAdapter.addAll(ll); panelAdapter.addAll(ll);
//panelAdapter = new PanelAdapter(ll); //panelAdapter = new PanelAdapter(ll);
// Cambio el color del fondo // Cambio el color del fondo
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout); RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
//rl.setBackgroundColor(Color.RED); //rl.setBackgroundColor(Color.RED);
if (p.get_color() != -1){ if (p.get_color() != -1){
rl.setBackgroundColor(p.get_color()); rl.setBackgroundColor(p.get_color());
panelAdapter.setColor(p.get_darkner_color()); panelAdapter.setColor(p.get_darkner_color());
} }
actualCategory = p; actualCategory = p;
Toast.makeText(context, "El picto pulsado es una categoría", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "El picto pulsado es una categoría", Toast.LENGTH_SHORT).show();
PCBcontext.getActionLog().log(new PictoAction(PictoAction.SELECT, p)); PCBcontext.getActionLog().log(new PictoAction(PictoAction.SELECT, p));
}else if(tapeAdapter.getCount() < maxInTape){ }else if(tapeAdapter.getCount() < maxInTape){
// If the picto selected is not a category and the tape is not full, it is placed in tape // If the picto selected is not a category and the tape is not full, it is placed in tape
tapeAdapter.addItem(p); tapeAdapter.addItem(p);
tapeAdapter.notifyDataSetChanged(); tapeAdapter.notifyDataSetChanged();
Log.d(LOG_TAG, "Picto añadido a la CINTA"); Log.d(LOG_TAG, "Picto añadido a la CINTA");
panelAdapter.clear(); panelAdapter.clear();
panelAdapter.addAll(ll); panelAdapter.addAll(ll);
panelAdapter.setColor(Color.parseColor("#AFAFAF")); panelAdapter.setColor(Color.parseColor("#AFAFAF"));
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout); RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
rl.setBackgroundColor(Color.parseColor("#BDBDBD")); rl.setBackgroundColor(Color.parseColor("#BDBDBD"));
// Call to static log method // Call to static log method
PCBcontext.getActionLog().log(new PictoAction(PictoAction.ADD, p)); PCBcontext.getActionLog().log(new PictoAction(PictoAction.ADD, p));
// Send websocket notification // Send websocket notification
// when clicking a picto, the activity goes to the main category view // when clicking a picto, the activity goes to the main category view
actualCategory = null; actualCategory = null;
}
} }
} }
} }
...@@ -297,6 +343,11 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -297,6 +343,11 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
tapeAdapter.deleteAll(); tapeAdapter.deleteAll();
tapeAdapter.notifyDataSetChanged(); tapeAdapter.notifyDataSetChanged();
panelAdapter.setColor(Color.parseColor("#AFAFAF"));
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
rl.setBackgroundColor(Color.parseColor("#BDBDBD"));
// Load the categories // Load the categories
load_pictos(arg0); load_pictos(arg0);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="15dp" android:paddingRight="10dp"
android:paddingTop="10dp" android:paddingTop="10dp"
android:orientation="horizontal" android:orientation="horizontal"
android:background="#BDBDBD" android:background="#BDBDBD"
...@@ -22,16 +22,14 @@ ...@@ -22,16 +22,14 @@
android:accessibilityLiveRegion="none" android:accessibilityLiveRegion="none"
android:background="@android:color/holo_red_light" android:background="@android:color/holo_red_light"
android:clickable="false" android:clickable="false"
android:visibility="visible"
android:layout_alignParentTop="true"> android:layout_alignParentTop="true">
</GridView> </GridView>
<ImageButton <ImageButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="20dp" android:paddingLeft="20dp"
android:src="@drawable/ic_action_1" android:src="@drawable/play64"
android:background="@null" android:background="@null"
android:id="@+id/button_tts" android:id="@+id/button_tts"
android:layout_toRightOf="@+id/tape_grid_view" android:layout_toRightOf="@+id/tape_grid_view"
...@@ -41,11 +39,11 @@ ...@@ -41,11 +39,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="20dp" android:paddingLeft="20dp"
android:src="@drawable/ic_action" android:src="@drawable/back64"
android:background="@null" android:background="@null"
android:id="@+id/button_delete" android:id="@+id/button_delete"
android:layout_toRightOf="@+id/tape_grid_view" android:layout_toRightOf="@+id/tape_grid_view"
android:layout_alignParentTop="true"/> android:layout_below="@+id/button_tts"/>
<GridView <GridView
android:id="@+id/panel_grid_view" android:id="@+id/panel_grid_view"
......
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