Commit 70f85c8e by german

Interfaz del menú de picto modificada (aun falta funcionalidad)

parent fe7a35d9
...@@ -14,6 +14,8 @@ import android.database.Cursor; ...@@ -14,6 +14,8 @@ import android.database.Cursor;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.media.Ringtone; import android.media.Ringtone;
import android.media.RingtoneManager; import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
...@@ -43,7 +45,6 @@ import android.widget.FrameLayout; ...@@ -43,7 +45,6 @@ import android.widget.FrameLayout;
import android.widget.GridView; import android.widget.GridView;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
...@@ -68,6 +69,7 @@ import org.json.JSONException; ...@@ -68,6 +69,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -76,6 +78,9 @@ import java.util.Locale; ...@@ -76,6 +78,9 @@ import java.util.Locale;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static android.graphics.Color.BLACK;
import static android.graphics.Color.argb;
public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener { public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener {
float firstTouchX = -1; float firstTouchX = -1;
...@@ -125,7 +130,8 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -125,7 +130,8 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Variables used on the picto menu (only supervisors) //Variables used on the picto menu (only supervisors)
private RadialMenuWidget PieMenu; private RadialMenuWidget PieMenu;
private LinearLayout ll; private ImageView detail;
private RelativeLayout ll;
@Override @Override
...@@ -866,9 +872,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -866,9 +872,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Si es supervisor hacer aparecer el menú de opciones del picto //Si es supervisor hacer aparecer el menú de opciones del picto
View pictoSquare = getCurrentPictoGridAdapter().getView(position,view,parent); View pictoSquare = getCurrentPictoGridAdapter().getView(position,view,parent);
if(pictoSquare.getWidth() == 100){ //Si esta en formato de pictos normal if(pictoSquare.getWidth() == 100){ //Si esta en formato de pictos normal
createMenuForPicto(0,(int) pictoSquare.getX(),(int) pictoSquare.getY(), p.get_column(), p.get_row()); createMenuForPicto(0,p);
}else{ }else{
createMenuForPicto(1,(int) pictoSquare.getX(),(int) pictoSquare.getY(), p.get_column(), p.get_row()); createMenuForPicto(1,p);
} }
//p.alter_status(); //p.alter_status();
getCurrentPictoGridAdapter().notifyDataSetChanged(); getCurrentPictoGridAdapter().notifyDataSetChanged();
...@@ -1251,29 +1257,63 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1251,29 +1257,63 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
int red = Color.red(color); int red = Color.red(color);
int green = Color.green(color); int green = Color.green(color);
int blue = Color.blue(color); int blue = Color.blue(color);
return Color.argb(alpha, red, green, blue); return argb(alpha, red, green, blue);
} }
private void createMenuForPicto(int tamPicto,int posX, int posY, int nCol, int nFila){ private void createMenuForPicto(int tamPicto, Picto picto){
ll = new LinearLayout(this); ll = new RelativeLayout(PCBcontext.getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); RelativeLayout.LayoutParams.MATCH_PARENT);
addContentView(ll, params); addContentView(ll, params);
ll.setBackgroundColor(argb(180,0,0,0));
detail = new ImageView(PCBcontext.getContext());
int centerX = PictogramActivity.this.getResources().getDisplayMetrics().widthPixels/2;
int centerY = PictogramActivity.this.getResources().getDisplayMetrics().heightPixels/2;
if(tamPicto==0){
centerY += 100;
detail.setMaxWidth(90);
}else{
centerY += 135;
detail.setMaxWidth(115);
}
PieMenu = new RadialMenuWidget(PCBcontext.getContext()); PieMenu = new RadialMenuWidget(PCBcontext.getContext());
PieMenu.setAnimationSpeed(0L); PieMenu.setAnimationSpeed(0L);
//int xLayoutSize = ll.getWidth();
//int yLayoutSize = ll.getHeight();
//PieMenu.setSourceLocation(posX,posY);
/**Para obtener posicion x => posX + tamPicto/2 + nºcolumna(considerar espacios entre pictos) 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());
ll.addView(PieMenu);
try {
detail.setImageBitmap(picto.get_bitmap(PCBcontext.getContext()));
detail.setBackgroundColor(picto.get_color());
detail.setX(centerX+10);
detail.setY(centerY - (picto.get_bitmap(PCBcontext.getContext()).getHeight()));
} catch (IOException e) {
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)*/ 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 //Segun tamaño de los pictos pongo el menu de un tamaño o de otro y calculo distancias
//TODO: Cambiar tamaño del menu segun tamaño del pictograma /*if(tamPicto==0){
if(tamPicto==0){
posX = posX + nCol + 100/2; posX = posX + nCol + 100/2;
posY = posY + nFila + 94/2 + 100; posY = posY + nFila + 94/2 + 100;
PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado) PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado)
...@@ -1283,21 +1323,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1283,21 +1323,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
posY = posY + nFila + 115/2 + 145; posY = posY + nFila + 115/2 + 145;
PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado) PieMenu.setCenterLocation(posX,posY); //Posicion del widget en la pantalla(Encima del picto seleccionado)
PieMenu.setIconSize(10,25); PieMenu.setIconSize(10,25);
} }*/
PieMenu.setIconSize(20,35); //Tamaño del icono
//PieMenu.setTextSize(13); //Tamaño del texto
//PieMenu.setSourceLocation(xLayoutSize,yLayoutSize);
PieMenu.setIconSize(10,25);
PieMenu.setTextSize(13);
PieMenu.setCenterCircle(new Close());
PieMenu.addMenuEntry(new DisablePictoMenu());
PieMenu.addMenuEntry(new EditLegendMenu());
PieMenu.addMenuEntry(new ChangePictoMenu());
PieMenu.addMenuEntry(new UnlockPictoMenu());
ll.addView(PieMenu);
} }
//TODO: Añadir iconos y cambiarlos en cada boton //TODO: Añadir iconos y cambiarlos en cada boton
...@@ -1312,7 +1338,8 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1312,7 +1338,8 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
//Metodo para realizar acciones si se pulsa //Metodo para realizar acciones si se pulsa
public void menuActiviated() public void menuActiviated()
{ {
((LinearLayout)PieMenu.getParent()).removeView(PieMenu); ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
} }
} }
...@@ -1329,11 +1356,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1329,11 +1356,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
} }
//Edit legend of picto menu button //Edit legend of picto menu button
public static class EditLegendMenu implements RadialMenuWidget.RadialMenuEntry public static class EditMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "IconOnly"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.disabled_picto; } 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()
{ {
...@@ -1341,11 +1368,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1341,11 +1368,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
} }
//Change image of picto menu button //Change image of picto menu button
public static class ChangePictoMenu implements RadialMenuWidget.RadialMenuEntry public static class SetInvisibleMenu implements RadialMenuWidget.RadialMenuEntry
{ {
public String getName() { return "IconOnly"; } public String getName() { return "IconOnly"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.disabled_picto; } 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()
{ {
...@@ -1357,7 +1384,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -1357,7 +1384,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
{ {
public String getName() { return "IconOnly"; } public String getName() { return "IconOnly"; }
public String getLabel() { return null; } public String getLabel() { return null; }
public int getIcon() { return R.drawable.disabled_picto; } 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()
{ {
......
...@@ -20,9 +20,12 @@ import android.view.animation.DecelerateInterpolator; ...@@ -20,9 +20,12 @@ 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.tools.PCBcontext;
public class RadialMenuWidget extends View { public class RadialMenuWidget extends View {
//Defines the interface //Defines the interface
...@@ -34,7 +37,6 @@ public class RadialMenuWidget extends View { ...@@ -34,7 +37,6 @@ public class RadialMenuWidget extends View {
void menuActiviated(); void menuActiviated();
} }
private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>(); private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>();
private RadialMenuEntry centerCircle = null; private RadialMenuEntry centerCircle = null;
...@@ -86,8 +88,8 @@ public class RadialMenuWidget extends View { ...@@ -86,8 +88,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 +127,12 @@ public class RadialMenuWidget extends View { ...@@ -125,13 +127,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();
...@@ -657,6 +658,7 @@ public class RadialMenuWidget extends View { ...@@ -657,6 +658,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 +666,17 @@ public class RadialMenuWidget extends View { ...@@ -664,18 +666,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 +757,6 @@ public class RadialMenuWidget extends View { ...@@ -756,7 +757,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 );
...@@ -887,6 +887,9 @@ public class RadialMenuWidget extends View { ...@@ -887,6 +887,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