Commit 51e16563 by German Callejas

Añadido submenu de opciones para editar la leyenda o la imagen (Falta funcionalidad)

Arreglado tema de obtener la expresion del picto en el PCB del JSON
parent 33d65db5
......@@ -117,6 +117,18 @@ Picto extends Img {
*/
public String get_url() {return this.url;}
/**
*
* @param newTranslation
*/
public void set_translation(String newTranslation){
this.translation = newTranslation;
try {
this.attributes.put(JSON_ATTTRS.EXPRESSION,newTranslation);
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
*
......@@ -378,9 +390,6 @@ Picto extends Img {
* @return true if current status is enabled. False in other case.
*/
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;*/
Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled());
try {
this.attributes.put(JSON_ATTTRS.STATUS, status);
......
......@@ -170,17 +170,18 @@ public class Vocabulary implements Iterable<Picto> {
final String jexpression_text = "text";
Picto[] pictos = new Picto[result.length()];
JSONObject picto = null, expression = null, attributes = null;
JSONObject picto = null, attributes = null;
String expression;
JSONObject ojpicto=null;
try {
for (int i=0; i < result.length(); i++) {
ojpicto=result.getJSONObject(i);
picto = ojpicto.getJSONObject(jpicto);
expression = ojpicto.getJSONObject(jexpression);
expression = ojpicto.getString(jexpression);
attributes = ojpicto.getJSONObject(jattributes);
pictos[i] = new Picto(picto.getInt(jid),
picto.getString(juri),
expression.getString(jexpression_text),
expression,
attributes);
}
synchronizeImgs(pictos);
......
......@@ -14,8 +14,6 @@ import android.database.Cursor;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
......@@ -38,6 +36,7 @@ import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.EditText;
......@@ -50,6 +49,7 @@ import android.widget.Toast;
import com.yottacode.pictogram.action.PictosAction;
import com.yottacode.pictogram.action.TalkAction;
import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
......@@ -69,7 +69,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
......@@ -80,6 +79,7 @@ import java.util.concurrent.TimeUnit;
import static android.graphics.Color.BLACK;
import static android.graphics.Color.argb;
import static android.graphics.Color.rgb;
public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener {
......@@ -1261,6 +1261,93 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
}
/**Function for open a new View for change the expression of a picto
*
* @param picto
*/
public void createViewForExpression(final Picto picto){
ll = new RelativeLayout(PCBcontext.getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
addContentView(ll, params);
ll.setBackgroundColor(argb(180,0,0,0));
ll.setClickable(false);
//Parameters for hide navigation bar when u save or cancel
final View decorView = getWindow().getDecorView();
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
final EditText leyenda = new EditText(PCBcontext.getContext());
leyenda.setBackgroundColor(rgb(221, 221, 211));
leyenda.setWidth(400);
leyenda.setMaxLines(1);
leyenda.setClickable(true);
leyenda.setTextSize(25);
leyenda.setX(PictogramActivity.this.getResources().getDisplayMetrics().widthPixels/2 - 400);
leyenda.setY(PictogramActivity.this.getResources().getDisplayMetrics().heightPixels/2 - 50);
leyenda.setTextColor(BLACK);
if(picto.get_translation()!=null){
leyenda.setText(picto.get_translation());
}else{
leyenda.setText("Sin Descripción");
}
//Mostrar teclado automaticamente
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
ImageButton botonOk = new ImageButton(PCBcontext.getContext());
botonOk.setImageResource(android.R.drawable.ic_menu_save);
botonOk.setX(PictogramActivity.this.getResources().getDisplayMetrics().widthPixels/2 + 10);
botonOk.setY(PictogramActivity.this.getResources().getDisplayMetrics().heightPixels/2 - 50);
botonOk.setBackgroundColor(rgb(221,221,221));
botonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
picto.set_translation(leyenda.getText().toString());
imm.hideSoftInputFromWindow(leyenda.getWindowToken(), 0);
picto.set_local_status(true);
if (!picto.is_local()) {
new PictoUploader(picto).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, picto));
}
getCurrentPictoGridAdapter().notifyDataSetChanged();
ll.setVisibility(View.GONE);
//Hide navigation bar
decorView.setSystemUiVisibility(uiOptions);
}
});
ImageButton botonSalir = new ImageButton(PCBcontext.getContext());
botonSalir.setImageResource(android.R.drawable.ic_menu_close_clear_cancel);
botonSalir.setX(PictogramActivity.this.getResources().getDisplayMetrics().widthPixels/2 + 80);
botonSalir.setY(PictogramActivity.this.getResources().getDisplayMetrics().heightPixels/2 - 50);
botonSalir.setBackgroundColor(rgb(221,221,221));
botonSalir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imm.hideSoftInputFromWindow(leyenda.getWindowToken(), 0);
ll.setVisibility(View.GONE);
//Hide navigation bar
decorView.setSystemUiVisibility(uiOptions);
}
});
ll.addView(leyenda);
ll.addView(botonOk);
ll.addView(botonSalir);
leyenda.requestFocus();
imm.showSoftInput(leyenda, InputMethodManager.SHOW_FORCED);
}
/**Function for build a radial menu
*
* @param tamPicto
* @param picto
*/
private void createMenuForPicto(int tamPicto, Picto picto){
ll = new RelativeLayout(PCBcontext.getContext());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
......@@ -1349,26 +1436,6 @@ 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);
}
}
//Change image of picto menu button
public class SetInvisibleMenu implements RadialMenuWidget.RadialMenuEntry
{
......@@ -1411,4 +1478,61 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
}
}
//Edit 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; }
private List<RadialMenuWidget.RadialMenuEntry> children = new ArrayList<>(Arrays.asList( new EditTextPicto(this.p), new EditImage(this.p)));
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return children; }
public void menuActiviated()
{
/**TODO: Llamar a la interfaz de editar foto y leyenda*/
Toast.makeText(PCBcontext.getContext(),"Editar Picto", Toast.LENGTH_SHORT).show();
}
}
//Edit legend text of picto button
public class EditTextPicto implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public EditTextPicto(Picto picto){
this.p = picto;
}
public String getName() { return "editText"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit_text; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
Toast.makeText(PCBcontext.getContext(),"Editar Texto", Toast.LENGTH_SHORT).show();
ll.setVisibility(View.GONE);
((RelativeLayout)PieMenu.getParent()).removeView(PieMenu);
createViewForExpression(this.p);
}
}
public class EditImage implements RadialMenuWidget.RadialMenuEntry
{
Picto p;
public EditImage(Picto picto){
this.p = picto;
}
public String getName() { return "editImage"; }
public String getLabel() { return null; }
public int getIcon() { return R.drawable.edit_picture; }
public List<RadialMenuWidget.RadialMenuEntry> getChildren() { return null; }
public void menuActiviated()
{
/**TODO: Llamar a la interfaz de editar foto*/
Toast.makeText(PCBcontext.getContext(),"Editar Imagen", Toast.LENGTH_SHORT).show();
}
}
}
......@@ -39,14 +39,16 @@ public class RadialMenuWidget extends View {
}
private List<RadialMenuEntry> menuEntries = new ArrayList<RadialMenuEntry>();
private List<RadialMenuEntry> menuEntries2 = new ArrayList<RadialMenuEntry>();
private RadialMenuEntry centerCircle = null;
private int variable;
private float screen_density = getContext().getResources().getDisplayMetrics().density;
private int defaultColor = Color.rgb(221, 221, 211); //default color of wedge pieces
private int defaultAlpha = 255; //transparency of the colors, 255=Opague, 0=Transparent
private int wedge2Color = Color.rgb(50, 50, 50); //default color of wedge pieces
private int wedge2Alpha = 210;
private int wedge2Color = Color.rgb(221, 221, 211); //default color of wedge pieces
private int wedge2Alpha = 255;
private int outlineColor = Color.rgb(150, 150, 150); //color of outline
private int outlineAlpha = 255; //transparency of outline
private int selectedColor = Color.rgb(70, 130, 180); //color to fill when something is selected
......@@ -221,13 +223,12 @@ public class RadialMenuWidget extends View {
//If outer ring is not enabled, then executes event
} else {
menuEntries.get(i).menuActiviated();
variable = i;
//Figures out how many outer rings
if (menuEntries.get(i).getChildren() != null) {
determineOuterWedges(menuEntries.get(i));
enabled = f;
animateOuterOut = true; //sets Wedge2Shown = true;
} else {
Wedge2Shown = false;
}
......@@ -237,14 +238,18 @@ public class RadialMenuWidget extends View {
}
}
} else if (selected2 != null){
for (int i = 0; i < Wedges2.length; i++) {
Wedge f = Wedges2[i];
if (f == selected2) {
animateOuterIn = true; //sets Wedge2Shown = false;
enabled = null;
selected = null;
}
}
for (int i = 0; i < Wedges2.length; i++) {
//for (int j = 0; j < menuEntries.get(i).getChildren().size(); j++) {
Wedge f = Wedges2[i];
if (f == selected2) {
animateOuterIn = true; //sets Wedge2Shown = false;
enabled = null;
selected = null;
menuEntries.get(variable).getChildren().get(i).menuActiviated();
}
//}
}
} 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();
......
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