Varios bugs solucionados

parent 6383f43e
......@@ -51,6 +51,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
private static final String TAG_PIC = "pic";
private static final String TAG_LANG = "lang";
private static final String TAG_ATTRIBUTES = "attributes";
private static final String TAG_SUPERVISION = "supervision";
private int sup_id;
......@@ -153,6 +154,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
public void result(JSONArray students_supervisors) { //FERNANDO
try {
// Saco los pares estudiante-supervisor
//Log.d(LOG_TAG, "JSON:"+students_supervisors);
Log.d(LOG_TAG, "students_supervisors size:" + students_supervisors.length());
// looping through All Students
Vector<User> users = new Vector<User>(students_supervisors.length());
......@@ -189,14 +191,18 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener,
String st_lang = st.getString(TAG_LANG);
//st_lang = "es-es";
String st_attributes = st.getString(TAG_ATTRIBUTES);
Integer st_supervision = st.getInt(TAG_SUPERVISION);
//Log.d(LOG_TAG, "student pic:" + st_pic);
// Añado un par <student-supervisor>
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,
sup_id, "", "", "", "M", "es-es", "");
users.add(student);
int st_supervision_int = st_supervision.intValue();
if (st_supervision_int==2){
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
......
......@@ -15,11 +15,16 @@ import android.widget.Toast;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.PCBDBHelper;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
public class MainActivity extends Activity {
......@@ -35,28 +40,13 @@ public class MainActivity extends Activity {
// For deactivating the lock screen (just before setContentView)
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);
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);
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
......
......@@ -19,6 +19,7 @@ import android.util.Log;
import android.view.Display;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
......@@ -78,6 +79,12 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
// String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
float xAxis = 0f;
float yAxis = 0f;
float lastXAxis = 0f;
float lastYAxis = 0f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -130,6 +137,43 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
tapeGridView.getLayoutParams().width = width - 120;
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 ImageButton deleteButton = (ImageButton) findViewById(R.id.button_delete);
//final Button deleteAllButton = (Button) findViewById(R.id.button_delete_all);
......@@ -167,64 +211,66 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
//rowNumberAdapter.notifyDataSetChanged();
Picto p = panelAdapter.getItem(position);
Log.d(LOG_TAG, "Clic en picto: " + p.toString());
//Log.d(LOG_TAG, "STATUS: " + p.get_status());
if (p!=null && !p.is_invisible() && p.is_enabled()){
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(p.get_id() != 0 &&
!p.get_status().equalsIgnoreCase("invisible") &&
!p.get_status().equalsIgnoreCase("disabled")) {
// If is not the blank picto, it isn't invisible or disabled
if(p.get_id() != 0 &&
!p.get_status().equalsIgnoreCase("invisible") &&
!p.get_status().equalsIgnoreCase("disabled")) {
LinkedList<Picto> ll = order(vocabulary.next(p));
//LinkedList<Picto> ll = vocabulary.next(p);
Log.d(LOG_TAG, "Lista de pictos recuperada: " + ll.toString());
LinkedList<Picto> ll = order(vocabulary.next(p));
//LinkedList<Picto> ll = vocabulary.next(p);
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 (p.is_category()) {
panelAdapter.clear();
// If the picto is a category
if (p.is_category()) {
panelAdapter.clear();
//if (panelAdapter.isEmpty())
// Log.d(LOG_TAG, "EMPTY !!!!");
//panelAdapter.deleteAll();
panelAdapter.addAll(ll);
//panelAdapter = new PanelAdapter(ll);
//if (panelAdapter.isEmpty())
// Log.d(LOG_TAG, "EMPTY !!!!");
//panelAdapter.deleteAll();
panelAdapter.addAll(ll);
//panelAdapter = new PanelAdapter(ll);
// Cambio el color del fondo
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
// Cambio el color del fondo
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
//rl.setBackgroundColor(Color.RED);
if (p.get_color() != -1){
rl.setBackgroundColor(p.get_color());
panelAdapter.setColor(p.get_darkner_color());
}
//rl.setBackgroundColor(Color.RED);
if (p.get_color() != -1){
rl.setBackgroundColor(p.get_color());
panelAdapter.setColor(p.get_darkner_color());
}
actualCategory = p;
Toast.makeText(context, "El picto pulsado es una categoría", Toast.LENGTH_SHORT).show();
PCBcontext.getActionLog().log(new PictoAction(PictoAction.SELECT, p));
actualCategory = p;
Toast.makeText(context, "El picto pulsado es una categoría", Toast.LENGTH_SHORT).show();
PCBcontext.getActionLog().log(new PictoAction(PictoAction.SELECT, p));
}else if(tapeAdapter.getCount() < maxInTape){
// If the picto selected is not a category and the tape is not full, it is placed in tape
tapeAdapter.addItem(p);
tapeAdapter.notifyDataSetChanged();
Log.d(LOG_TAG, "Picto añadido a la CINTA");
}else if(tapeAdapter.getCount() < maxInTape){
// If the picto selected is not a category and the tape is not full, it is placed in tape
tapeAdapter.addItem(p);
tapeAdapter.notifyDataSetChanged();
Log.d(LOG_TAG, "Picto añadido a la CINTA");
panelAdapter.clear();
panelAdapter.addAll(ll);
panelAdapter.setColor(Color.parseColor("#AFAFAF"));
panelAdapter.clear();
panelAdapter.addAll(ll);
panelAdapter.setColor(Color.parseColor("#AFAFAF"));
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
rl.setBackgroundColor(Color.parseColor("#BDBDBD"));
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
rl.setBackgroundColor(Color.parseColor("#BDBDBD"));
// Call to static log method
PCBcontext.getActionLog().log(new PictoAction(PictoAction.ADD, p));
// Send websocket notification
// Call to static log method
PCBcontext.getActionLog().log(new PictoAction(PictoAction.ADD, p));
// Send websocket notification
// when clicking a picto, the activity goes to the main category view
actualCategory = null;
// when clicking a picto, the activity goes to the main category view
actualCategory = null;
}
}
}
}
......@@ -297,6 +343,11 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
tapeAdapter.deleteAll();
tapeAdapter.notifyDataSetChanged();
panelAdapter.setColor(Color.parseColor("#AFAFAF"));
RelativeLayout rl = (RelativeLayout)findViewById(R.id.pictogramLayout);
rl.setBackgroundColor(Color.parseColor("#BDBDBD"));
// Load the categories
load_pictos(arg0);
}
......
......@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:orientation="horizontal"
android:background="#BDBDBD"
......@@ -22,16 +22,14 @@
android:accessibilityLiveRegion="none"
android:background="@android:color/holo_red_light"
android:clickable="false"
android:visibility="visible"
android:layout_alignParentTop="true">
</GridView>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:src="@drawable/ic_action_1"
android:src="@drawable/play64"
android:background="@null"
android:id="@+id/button_tts"
android:layout_toRightOf="@+id/tape_grid_view"
......@@ -41,11 +39,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:src="@drawable/ic_action"
android:src="@drawable/back64"
android:background="@null"
android:id="@+id/button_delete"
android:layout_toRightOf="@+id/tape_grid_view"
android:layout_alignParentTop="true"/>
android:layout_below="@+id/button_tts"/>
<GridView
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