Commit 86cfb41f by Fernando Martínez Santiago

Merge branch 'develop' of http://scm.ujaen.es/softuno/pictogram into develop

parents 793d3111 e7cf465f
...@@ -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
*/ */
......
...@@ -20,9 +20,13 @@ import android.view.animation.DecelerateInterpolator; ...@@ -20,9 +20,13 @@ import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation; import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation; import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
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;
public class RadialMenuWidget extends View { public class RadialMenuWidget extends View {
//Defines the interface //Defines the interface
...@@ -34,6 +38,7 @@ public class RadialMenuWidget extends View { ...@@ -34,6 +38,7 @@ 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;
...@@ -86,8 +91,8 @@ public class RadialMenuWidget extends View { ...@@ -86,8 +91,8 @@ public class RadialMenuWidget extends View {
private int textSize = scalePX(15); //TextSize private int textSize = scalePX(15); //TextSize
private int animateTextSize = textSize; private int animateTextSize = textSize;
private int xPosition = scalePX(120); //Center X location of Radial Menu private int xPosition; //Center X location of Radial Menu
private int yPosition = scalePX(120); //Center Y location of Radial Menu private int yPosition; //Center Y location of Radial Menu
private int xSource = 0; //Source X of clicked location private int xSource = 0; //Source X of clicked location
private int ySource = 0; //Center Y of clicked location private int ySource = 0; //Center Y of clicked location
...@@ -125,13 +130,12 @@ public class RadialMenuWidget extends View { ...@@ -125,13 +130,12 @@ public class RadialMenuWidget extends View {
private boolean animateOuterOut = false; private boolean animateOuterOut = false;
public RadialMenuWidget(Context context) { public RadialMenuWidget(Context context) {
super(context); super(context);
// Gets screen specs and defaults to center of screen // Gets screen specs and defaults to center of screen
this.xPosition = (getResources().getDisplayMetrics().widthPixels)/2; //this.xPosition = (getResources().getDisplayMetrics().widthPixels)/2;
this.yPosition = (getResources().getDisplayMetrics().heightPixels)/2; //this.yPosition = (getResources().getDisplayMetrics().heightPixels)/2;
determineWedges(); determineWedges();
onOpenAnimation(); onOpenAnimation();
...@@ -146,6 +150,7 @@ public class RadialMenuWidget extends View { ...@@ -146,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;
...@@ -201,6 +206,8 @@ public class RadialMenuWidget extends View { ...@@ -201,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();
...@@ -211,14 +218,41 @@ public class RadialMenuWidget extends View { ...@@ -211,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) {
...@@ -238,7 +272,7 @@ public class RadialMenuWidget extends View { ...@@ -238,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;
...@@ -246,7 +280,7 @@ public class RadialMenuWidget extends View { ...@@ -246,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;
...@@ -657,6 +691,7 @@ public class RadialMenuWidget extends View { ...@@ -657,6 +691,7 @@ public class RadialMenuWidget extends View {
paint.setStyle(Paint.Style.FILL); paint.setStyle(Paint.Style.FILL);
paint.setTextSize(headerTextSize); paint.setTextSize(headerTextSize);
c.drawText(headerString, headerTextLeft, headerTextBottom, paint); c.drawText(headerString, headerTextLeft, headerTextBottom, paint);
} }
} }
...@@ -664,18 +699,17 @@ public class RadialMenuWidget extends View { ...@@ -664,18 +699,17 @@ public class RadialMenuWidget extends View {
private int getIconSize(int iconSize, int minSize, int maxSize) { private int getIconSize(int iconSize, int minSize, int maxSize) {
if (iconSize > minSize) { if (iconSize > minSize) {
if (iconSize > maxSize) { if (iconSize > maxSize) {
return maxSize; return maxSize;
} else { //iconSize < maxSize } else { //iconSize < maxSize
return iconSize; return iconSize;
} }
} else { //iconSize < minSize } else { //iconSize < minSize
return minSize; return minSize;
} }
}
}
private void onOpenAnimation() { private void onOpenAnimation() {
...@@ -756,7 +790,6 @@ public class RadialMenuWidget extends View { ...@@ -756,7 +790,6 @@ public class RadialMenuWidget extends View {
return false; return false;
} }
public boolean addMenuEntry( RadialMenuEntry entry ) public boolean addMenuEntry( RadialMenuEntry entry )
{ {
menuEntries.add( entry ); menuEntries.add( entry );
...@@ -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;
...@@ -887,6 +924,9 @@ public class RadialMenuWidget extends View { ...@@ -887,6 +924,9 @@ public class RadialMenuWidget extends View {
return px_size; return px_size;
} }
public int getcRadius(){
return cRadius;
}
private void animateOuterWedges( int animation_direction) { private void animateOuterWedges( int animation_direction) {
......
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