PCB interfaz shows invisble pictos when superuser is logged. It's possible to…

PCB interfaz shows invisble pictos when superuser is logged. It's possible to enable/disable/make invisible pictos from the PCB
parent 3a6eb881
......@@ -35,11 +35,10 @@ public class ActionLog implements iRestapiListener {
*/
public void log(Action action) {
if (PCBcontext.getRoom().inRoom())
// PCBcontext.getRoom().emit(action.get_action(), action);
PCBcontext.getRoom().emit(action);
else {
// If there is no room, the action is stored in local DB
// If there is no room, the action is stored into the local DB
PCBcontext.getPcbdb().insertAction(action);
actions_buffer.add(action.getDescription());
Log.i(this.getClass().getCanonicalName(), " Batch action included: " + action.getDescription());
......
......@@ -175,7 +175,8 @@ public class Picto extends Img {
*/
public boolean is_invisible() {
try {
return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.INVISIBLE);
return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.INVISIBLE) ||
(this.is_category() && !PCBcontext.getVocabulary().isVisibleCategory(this.get_id()));
} catch (JSONException e) {
return false;
}
......
......@@ -246,16 +246,9 @@ public class User {
}
}
/**
*
* @return the id of the real user: stu or sup
public int get_id() {
return this.get_name_sup() == null ? this.get_id_stu() : this.get_id_sup();
public boolean is_supervisor() {
return get_id_sup()!=User.NO_SUPERVISOR;
}
*/
......
......@@ -311,14 +311,15 @@ public class Vocabulary implements Iterable<Picto> {
* @return list of pictos which should be selectable at the beginning of a sentence. Empty categories are removed
*/
public LinkedList<Picto> startSentence(){
Iterator<Picto> pictos=this.pictos.get(new Integer(Picto.NO_CATEGORY)).iterator();
return this.pictos.get(new Integer(Picto.NO_CATEGORY));
/*Iterator<Picto> pictos=this.pictos.get(new Integer(Picto.NO_CATEGORY)).iterator();
LinkedList<Picto> filteredPictos=new LinkedList<Picto>();
while (pictos.hasNext()) {
Picto picto = pictos.next();
if (!picto.is_category() || isVisibleCategory(picto.get_id()))
filteredPictos.add(picto);
}
return filteredPictos;
return filteredPictos;*/
}
/**
......@@ -326,13 +327,13 @@ public class Vocabulary implements Iterable<Picto> {
* @param id
* @return
*/
private boolean isVisibleCategory(int id) {
public boolean isVisibleCategory(int id) {
if (empty_category(id)) return false;
boolean visible=false;
for (Picto picto : this.pictos.get(id)) {
visible=picto.is_enabled();
visible=!picto.is_invisible();
if (visible) break;
}
return visible;
......
......@@ -2,6 +2,7 @@ package com.yottacode.pictogram.gui;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
......@@ -23,7 +24,9 @@ import android.widget.GridView;
import android.widget.ImageView;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.dao.PCBDBHelper;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.iVocabularyListener;
import com.yottacode.pictogram.tools.PCBcontext;
......@@ -146,7 +149,8 @@ public class PanelAdapter extends ArrayAdapter {
// Es un hueco en blanco
imageView.setImageAlpha(0);
} else{
Bitmap bmp1 = lPictos.get(position).get_bitmap(PCBcontext.getContext());
Picto picto =lPictos.get(position);
Bitmap bmp1 = picto.get_bitmap(PCBcontext.getContext());
if (bmp1 != null){
// Magnify
if(lPictos.get(position).is_magnify()){
......@@ -157,14 +161,14 @@ public class PanelAdapter extends ArrayAdapter {
imageView.setScaleY(1f);
}
// Estado de los pictos: enabled | disabled | invisible
String status = lPictos.get(position).get_status();
if(status.equalsIgnoreCase("invisible")){
imageView.setImageAlpha(0);
Log.d(LOG_TAG, "POSITION:" + position + " / STATUS: " + status);
if(picto.is_invisible()) {
imageView.setImageAlpha(PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 50 : 0);
imageView.setImageBitmap(bmp1);
Log.d(LOG_TAG, "POSITION:" + position + " / STATUS: " + picto.get_status());
//imageView.setImageBitmap(bmp1);
} else if(status.equalsIgnoreCase("disabled")){
}
if(picto.is_disabled()){
imageView.setImageAlpha(100); // Entre 0 y 255
Bitmap bmp2 = BitmapFactory.decodeResource(PCBcontext.getContext().getResources(), R.drawable.redcross3);
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
......@@ -185,7 +189,7 @@ public class PanelAdapter extends ArrayAdapter {
canvas.drawBitmap(bmp2, boardPosX, boardPosY, null);
*/
}
else{
if (picto.is_enabled()) {
/* AÑADO UN BORDE */
/*
final int BORDER_WIDTH = 1;
......
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