Commit e7cf465f by german

Funcionalidad añadida al menu de picto(solo local, hace falta salir y entrar…

Funcionalidad añadida al menu de picto(solo local, hace falta salir y entrar para poder ver los cambios en el picto)
parent 70f85c8e
...@@ -373,6 +373,30 @@ Picto extends Img { ...@@ -373,6 +373,30 @@ Picto extends Img {
} }
/** /**
* 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
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: 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);
set_local_status(true);
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
return is_enabled();
}
/**
* *
* @return true if the status of picto was modified from the PCB * @return true if the status of picto was modified from the PCB
*/ */
......
...@@ -1295,7 +1295,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1295,7 +1295,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
PieMenu.addMenuEntry(new DisablePictoMenu()); PieMenu.addMenuEntry(new DisablePictoMenu());
PieMenu.addMenuEntry(new SetInvisibleMenu()); PieMenu.addMenuEntry(new SetInvisibleMenu());
PieMenu.addMenuEntry(new EditMenu()); PieMenu.addMenuEntry(new EditMenu());
PieMenu.setPicto(picto);
ll.addView(PieMenu); ll.addView(PieMenu);
try { try {
...@@ -1344,50 +1346,58 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1344,50 +1346,58 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
} }
//Disable menu button //Disable menu button
public static class DisablePictoMenu implements RadialMenuWidget.RadialMenuEntry public class DisablePictoMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "disable"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.disabled_picto; } public int getIcon() { return R.drawable.disabled_picto; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
} }
} }
//Edit legend of picto menu button //Edit legend of picto menu button
public static class EditMenu implements RadialMenuWidget.RadialMenuEntry public class EditMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "edit"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit; } public int getIcon() { return R.drawable.edit; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
} }
} }
//Change image of picto menu button //Change image of picto menu button
public static class SetInvisibleMenu implements RadialMenuWidget.RadialMenuEntry public class SetInvisibleMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "invisible"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.eye_blocked; } public int getIcon() { return R.drawable.eye_blocked; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
} }
} }
//Activate/enable picto on vocabulary menu button //Activate/enable picto on vocabulary menu button
public static class UnlockPictoMenu implements RadialMenuWidget.RadialMenuEntry public class UnlockPictoMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "enable"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.unlock; } public int getIcon() { return R.drawable.unlock; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; } public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated() public void menuActiviated()
{ {
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
} }
} }
......
...@@ -24,6 +24,7 @@ import android.widget.ImageView; ...@@ -24,6 +24,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
public class RadialMenuWidget extends View { public class RadialMenuWidget extends View {
...@@ -37,6 +38,8 @@ public class RadialMenuWidget extends View { ...@@ -37,6 +38,8 @@ public class RadialMenuWidget extends View {
void menuActiviated(); void menuActiviated();
} }
private Picto picto;
private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>(); private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>();
private RadialMenuEntry centerCircle = null; private RadialMenuEntry centerCircle = null;
...@@ -147,6 +150,7 @@ public class RadialMenuWidget extends View { ...@@ -147,6 +150,7 @@ public class RadialMenuWidget extends View {
if (state == MotionEvent.ACTION_DOWN) { if (state == MotionEvent.ACTION_DOWN) {
//selected = null; //selected = null;
//selected2 = null; //selected2 = null;
inWedge = false; inWedge = false;
inWedge2 = false; inWedge2 = false;
inCircle = false; inCircle = false;
...@@ -202,6 +206,8 @@ public class RadialMenuWidget extends View { ...@@ -202,6 +206,8 @@ public class RadialMenuWidget extends View {
animateOuterIn = true; //sets Wedge2Shown = false; animateOuterIn = true; //sets Wedge2Shown = false;
} }
selected = null; selected = null;
//Close button message
Toast.makeText(getContext(), centerCircle.getName() + " pressed.", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), centerCircle.getName() + " pressed.", Toast.LENGTH_SHORT).show();
centerCircle.menuActiviated(); centerCircle.menuActiviated();
...@@ -212,14 +218,41 @@ public class RadialMenuWidget extends View { ...@@ -212,14 +218,41 @@ public class RadialMenuWidget extends View {
//Checks if a inner ring is enabled if so closes the outer ring an //Checks if a inner ring is enabled if so closes the outer ring an
if (enabled != null) { if (enabled != null) {
Toast.makeText(getContext(), "Closing outer ring", Toast.LENGTH_SHORT).show(); //Toast.makeText(getContext(), "Closing outer ring", Toast.LENGTH_SHORT).show();
enabled = null; enabled = null;
animateOuterIn = true; //sets Wedge2Shown = false; animateOuterIn = true; //sets Wedge2Shown = false;
//If outer ring is not enabled, then executes event //If outer ring is not enabled, then executes event
} else { } else {
Toast.makeText(getContext(), menuEntries.get(i).getName() + " pressed.", Toast.LENGTH_SHORT).show();
menuEntries.get(i).menuActiviated(); /**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;
}
//Figures out how many outer rings //Figures out how many outer rings
if (menuEntries.get(i).getChildren() != null) { if (menuEntries.get(i).getChildren() != null) {
...@@ -239,7 +272,7 @@ public class RadialMenuWidget extends View { ...@@ -239,7 +272,7 @@ public class RadialMenuWidget extends View {
for (int i = 0; i < Wedges2.length; i++) { for (int i = 0; i < Wedges2.length; i++) {
Wedge f = Wedges2[i]; Wedge f = Wedges2[i];
if (f == selected2) { if (f == selected2) {
Toast.makeText(getContext(), wedge2Data.getChildren().get(i).getName() + " pressed.", Toast.LENGTH_SHORT).show(); //Toast.makeText(getContext(), wedge2Data.getChildren().get(i).getName() + " pressed.", Toast.LENGTH_SHORT).show();
animateOuterIn = true; //sets Wedge2Shown = false; animateOuterIn = true; //sets Wedge2Shown = false;
enabled = null; enabled = null;
selected = null; selected = null;
...@@ -247,7 +280,7 @@ public class RadialMenuWidget extends View { ...@@ -247,7 +280,7 @@ public class RadialMenuWidget extends View {
} }
} else { } else {
//This is when something outside the circle or any of the rings is selected //This is when something outside the circle or any of the rings is selected
Toast.makeText(getContext(), "Area outside rings pressed.", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Pulse dentro del menú", Toast.LENGTH_SHORT).show();
//selected = null; //selected = null;
//enabled = null; //enabled = null;
...@@ -813,6 +846,10 @@ public class RadialMenuWidget extends View { ...@@ -813,6 +846,10 @@ public class RadialMenuWidget extends View {
onOpenAnimation(); onOpenAnimation();
} }
public void setPicto(Picto p){
picto = p;
}
public void setSourceLocation( int x, int y ) public void setSourceLocation( int x, int y )
{ {
this.xSource = x; 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