Commit 46f369eb by german

Menu para habilitar, deshabilitar, poner en invisible terminado. (Falta…

Menu para habilitar, deshabilitar, poner en invisible terminado. (Falta funcionalidad para editar imagen o leyenda)
parent 86cfb41f
......@@ -353,7 +353,7 @@ Picto extends Img {
* modify locally the status of the picto
* @return true if current status is enabled. False in other case.
*/
public boolean alter_status() {
/*public boolean alter_status() {
String status=is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: JSON_ATTTR_STATUS_VALUES.ENABLED;
......@@ -371,16 +371,16 @@ Picto extends Img {
}
return is_enabled();
}
*/
/**
* modify locally the status of the picto
* @param status the status that u press on the menu
* @return true if current status is enabled. False in other case.
*/
public boolean alter_status2(String status) {
status = is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
public boolean alter_status(String status) {
/*status = is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: JSON_ATTTR_STATUS_VALUES.ENABLED;
: JSON_ATTTR_STATUS_VALUES.ENABLED;*/
Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled());
try {
this.attributes.put(JSON_ATTTRS.STATUS, status);
......
......@@ -1290,13 +1290,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
PieMenu.setCenterLocation(centerX - (PieMenu.getcRadius()*2) - 50, centerY-(PieMenu.getcRadius()*2));
PieMenu.setIconSize(20,35); //Tamaño del icono
PieMenu.setCenterCircle(new Close());
PieMenu.addMenuEntry(new UnlockPictoMenu());
PieMenu.addMenuEntry(new DisablePictoMenu());
PieMenu.addMenuEntry(new SetInvisibleMenu());
PieMenu.addMenuEntry(new EditMenu());
PieMenu.setPicto(picto);
PieMenu.setCenterCircle(new Close(picto));
PieMenu.addMenuEntry(new UnlockPictoMenu(picto));
PieMenu.addMenuEntry(new DisablePictoMenu(picto));
PieMenu.addMenuEntry(new SetInvisibleMenu(picto));
PieMenu.addMenuEntry(new EditMenu(picto));
ll.addView(PieMenu);
......@@ -1309,30 +1307,16 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
e.printStackTrace();
}
ll.addView(detail);
/**Para el menú encima del picto
* Para obtener posicion x => posX + tamPicto/2 + nºcolumna(considerar espacios entre pictos)
Para obtener posicion y => posX + tamPicto/2 + nºfila(considerar espacios entre pictos) + tamBarraDialogo(100 o 145)*/
//Segun tamaño de los pictos pongo el menu de un tamaño o de otro y calculo distancias
/*if(tamPicto==0){
posX = posX + nCol + 100/2;
posY = posY + nFila + 94/2 + 100;
PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado)
PieMenu.setIconSize(10,20);
}else{
posX = posX + nCol + 115/2;
posY = posY + nFila + 115/2 + 145;
PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado)
PieMenu.setIconSize(10,25);
}*/
}
//TODO: Añadir iconos y cambiarlos en cada boton
/** Menu of picto classes */
//Close menu button
public class Close implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public Close(Picto picto){
this.p = picto;
}
public String getName() { return "Close"; }
public String getLabel() { return null; }
public int getIcon() { return android.R.drawable.ic_menu_close_clear_cancel; }
......@@ -1348,12 +1332,18 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Disable menu button
public class DisablePictoMenu implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public DisablePictoMenu(Picto picto){
this.p = picto;
}
public String getName() { return "disable"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.disabled_picto; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
p.alter_status("disabled");
getCurrentPictoGridAdapter().notifyDataSetChanged();
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
}
......@@ -1362,12 +1352,18 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Edit legend of picto menu button
public class EditMenu implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public EditMenu(Picto picto){
this.p = picto;
}
public String getName() { return "edit"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
/**TODO: Llamar a la interfaz de editar foto y leyenda*/
Toast.makeText(PCBcontext.getContext(),"Editar Picto", Toast.LENGTH_SHORT).show();
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
}
......@@ -1376,12 +1372,19 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Change image of picto menu button
public class SetInvisibleMenu implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public SetInvisibleMenu(Picto picto){
this.p = picto;
}
public String getName() { return "invisible"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.eye_blocked; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
p.alter_status("invisible");
getCurrentPictoGridAdapter().notifyDataSetChanged();
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
}
......@@ -1390,12 +1393,19 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Activate/enable picto on vocabulary menu button
public class UnlockPictoMenu implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public UnlockPictoMenu(Picto picto){
this.p = picto;
}
public String getName() { return "enable"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.unlock; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
p.alter_status("enabled");
getCurrentPictoGridAdapter().notifyDataSetChanged();
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
}
......
......@@ -38,8 +38,6 @@ public class RadialMenuWidget extends View {
void menuActiviated();
}
private Picto picto;
private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>();
private RadialMenuEntry centerCircle = null;
......@@ -208,7 +206,6 @@ public class RadialMenuWidget extends View {
selected = null;
//Close button message
Toast.makeText(getContext(), centerCircle.getName() + " pressed.", Toast.LENGTH_SHORT).show();
centerCircle.menuActiviated();
} else if (selected != null){
......@@ -218,41 +215,12 @@ public class RadialMenuWidget extends View {
//Checks if a inner ring is enabled if so closes the outer ring an
if (enabled != null) {
//Toast.makeText(getContext(), "Closing outer ring", Toast.LENGTH_SHORT).show();
enabled = null;
animateOuterIn = true; //sets Wedge2Shown = false;
//If outer ring is not enabled, then executes event
} else {
/**TODO: Gestionar aqui los mensajes de los botones y realizar la accion que corresponda al picto(switch)
* Ahora mismo fundiona en local*/
switch (menuEntries.get(i).getName()){
case "disable":
if(picto.get_status() == "invisible"){
Toast.makeText(getContext(),"El picto esta inactivo", Toast.LENGTH_SHORT).show();
}
picto.alter_status2("disabled");
Toast.makeText(getContext(),"Picto Deshabilitado", Toast.LENGTH_SHORT).show();
menuEntries.get(i).menuActiviated();
break;
case "enable":
picto.alter_status2("enabled");
Toast.makeText(getContext(),"Picto Habilitado", Toast.LENGTH_SHORT).show();
menuEntries.get(i).menuActiviated();
break;
case "invisible":
picto.alter_status2("invisible");
Toast.makeText(getContext(),"Picto Invisible", Toast.LENGTH_SHORT).show();
menuEntries.get(i).menuActiviated();
break;
case "edit":
Toast.makeText(getContext(),"Editar Picto", Toast.LENGTH_SHORT).show();
menuEntries.get(i).menuActiviated();
break;
}
menuEntries.get(i).menuActiviated();
//Figures out how many outer rings
if (menuEntries.get(i).getChildren() != null) {
......@@ -272,16 +240,14 @@ public class RadialMenuWidget extends View {
for (int i = 0; i < Wedges2.length; i++) {
Wedge f = Wedges2[i];
if (f == selected2) {
//Toast.makeText(getContext(), wedge2Data.getChildren().get(i).getName() + " pressed.", Toast.LENGTH_SHORT).show();
animateOuterIn = true; //sets Wedge2Shown = false;
enabled = null;
selected = null;
animateOuterIn = true; //sets Wedge2Shown = false;
enabled = null;
selected = null;
}
}
} else {
//This is when something outside the circle or any of the rings is selected
Toast.makeText(getContext(), "Pulse dentro del menú", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), "Pulse dentro del menú", Toast.LENGTH_SHORT ).show();
//selected = null;
//enabled = null;
}
......@@ -846,10 +812,6 @@ public class RadialMenuWidget extends View {
onOpenAnimation();
}
public void setPicto(Picto p){
picto = p;
}
public void setSourceLocation( int x, int y )
{
this.xSource = x;
......
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