issue #816 closed

parent 42b3ba10
......@@ -38,6 +38,7 @@ public class VocabularyTalk implements Emitter.Listener {
final String action_add="add";
final String action_delete="delete";
JSONObject msg = (JSONObject) args[0];
try {
Log.i(LOG_TAG, "raw Received message " +msg.toString());
......
package com.yottacode.pictogram.tabletlibrary.gui;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
......
......@@ -31,7 +31,6 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
......@@ -918,6 +917,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
if (lp.size()>0 && !PictogramActivity.this.tapeAdapter.play()) {
PCBcontext.getActionLog().log(new PictosAction(lp));
tapeAdapter.ttsAllNew(tts);
if (!PCBcontext.getPcbdb().getCurrentUser().delete_tape_after_delivery()) animateTapeView(0,(ViewGroup)arg0.getParent());
}
}
}
......@@ -1253,6 +1253,58 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
}
public void animateTapeView(final int position, final ViewGroup view) {
GridView gridview = (GridView)view.getChildAt(1);
RelativeLayout relativeLayout=(RelativeLayout)(gridview.getChildAt(position));
FrameLayout layout=(FrameLayout)(relativeLayout.getChildAt(0));
final ImageView v=(ImageView)(layout.getChildAt(0));
final int orange = ContextCompat.getColor(PCBcontext.getContext(), R.color.red);
final ValueAnimator colorAnim = ObjectAnimator.ofFloat(0f, 1f, 0f);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float mul = (Float) animation.getAnimatedValue();
int alphaOrange = adjustAlpha(orange, mul);
v.setColorFilter(alphaOrange, PorterDuff.Mode.SRC_ATOP);
v.setBackgroundColor(alphaOrange);
v.setPadding(0, 0, 0, 0);
if (mul == 0.0) {
v.setColorFilter(0);
}
}
});
colorAnim.addListener(new ValueAnimator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
v.setColorFilter(0);
v.setBackgroundColor(ContextCompat.getColor(PCBcontext.getContext(), R.color.picto_default_background));
if (position <(tapeAdapter.getCount()-1)) animateTapeView(position + 1, view);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
colorAnim.setDuration(tapeAdapter.getItem(position).get_translation().length()*100);
colorAnim.start();
}
public static int adjustAlpha(int color, float factor) {
int alpha = Math.round(Color.alpha(color) * factor);
int red = Color.red(color);
......@@ -1385,7 +1437,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
PieMenu.addMenuEntry(new UnlockPictoMenu(picto));
PieMenu.addMenuEntry(new DisablePictoMenu(picto));
PieMenu.addMenuEntry(new SetInvisibleMenu(picto));
PieMenu.addMenuEntry(new EditMenu(picto));
//PieMenu.addMenuEntry(new EditMenu(picto));
ll.addView(PieMenu);
......
......@@ -19,15 +19,15 @@ public class TapeAdapter extends BaseAdapter {
//private Context mContext;
private LinkedList<Picto> pictoLinkedList;
private boolean play=false;
private boolean play = false;
public TapeAdapter(){
public TapeAdapter() {
//mContext = c;
pictoLinkedList = new LinkedList<Picto>(); // the list begins empty
}
@Override
public int getCount(){
public int getCount() {
return pictoLinkedList.size();
}
......@@ -44,37 +44,40 @@ public class TapeAdapter extends BaseAdapter {
}
// AÑADIR ITEM AL ADAPTADOR
public void addItem(Picto p){
public void addItem(Picto p) {
pictoLinkedList.add(p);
}
// ELIMINAR ITEM DEL ADAPTADOR
public void deleteItem(int position){
public void deleteItem(int position) {
pictoLinkedList.remove(position);
}
// ELIMINAR el último ITEM DEL ADAPTADOR
public void deleteLastView(){
public void deleteLastView() {
// Controlar excepcion al intentar eliminar el último cuando no hay elementos
try{
try {
pictoLinkedList.removeLast();
}catch(ArrayIndexOutOfBoundsException exception){
} catch (ArrayIndexOutOfBoundsException exception) {
Log.e("Excepción", "ArrayIndexOutOfBounds: " + exception.getMessage());
}
}
// ELIMINAR TODOS LOS ITEMS DEL ADAPTADOR
public void endPlay(){
if (PCBcontext.getPcbdb().getCurrentUser().delete_tape_after_delivery()) pictoLinkedList.clear();
play=false;
public void endPlay() {
if (PCBcontext.getPcbdb().getCurrentUser().delete_tape_after_delivery())
pictoLinkedList.clear();
play = false;
}
// DEVUELVE TODOS LOS ELEMENTOS
public LinkedList<Picto> getAll(){ return pictoLinkedList; }
public LinkedList<Picto> getAll() {
return pictoLinkedList;
}
// Devuelvo la cadena actual como un String
public String getAllAsString(){
public String getAllAsString() {
String complete = "";
Iterator<Picto> iterator = pictoLinkedList.iterator();
while (iterator.hasNext()) {
......@@ -85,19 +88,18 @@ public class TapeAdapter extends BaseAdapter {
}
// DEVUELVE último elemento
public Picto getLastItem(){
public Picto getLastItem() {
return pictoLinkedList.getLast();
}
// Devuelve true o false si tiene o no elementos la lista de pictos
public boolean hasElements(){
public boolean hasElements() {
return (pictoLinkedList.size() > 0);
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
public View getView(int position, View convertView, ViewGroup parent) {
View pictoView = PictoItemViewGenerator.getPictoView(
this.pictoLinkedList.get(position),
convertView,
......@@ -107,7 +109,7 @@ public class TapeAdapter extends BaseAdapter {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void ttsAllNew(TTSHelper tts) {
this.play=true;
this.play = true;
String input = getAllAsString();
tts.play(input);
}
......@@ -115,4 +117,6 @@ public class TapeAdapter extends BaseAdapter {
public boolean play() {
return this.play;
}
}
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