grabacion temporal de imagenes

revisión de interfaz de edicion de pictos
parent d9faa166
......@@ -9,7 +9,6 @@ import com.koushikdutta.ion.Response;
import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
......@@ -24,7 +23,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
/**
......@@ -318,7 +316,7 @@ public class PictoUploader {
uploadTranslation(picto.get_id(), listener);
}
}else{
GUITools.show_alert(PCBcontext.getActivityContext(), Integer.parseInt(R.string.upload_error+"Imagen"), PictoUploader.this.picto.get_translation());
GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error, PictoUploader.this.picto.get_translation());
}
}
......
......@@ -90,14 +90,18 @@ public final class PCBcontext {
}
public static void unset_user() {
Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
Log.e(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
if (room!=null) room.exit();
pcbdb = null;
room = null;
vocabulary = null;
getNetService().notifyStatus();
}
@Override
protected void finalize() {
Log.e("PCBcontext", "FINALIZE Pictogram Activity");
}
/**
*
* @return true if a given user has been logged into the system (the login window was successfully filled)
......
package com.yottacode.tools;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
......@@ -8,12 +9,22 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by Fernando on 15/03/2016.
*/
public class BitmapTools {
Bitmap bitmap;
private static String LOG_TAG=BitmapTools.class.getName();
Bitmap bitmap;
public BitmapTools(Bitmap bitmap) { this.bitmap=bitmap;}
public Bitmap get() {return this.bitmap;}
......@@ -167,4 +178,36 @@ public class BitmapTools {
canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(),
(int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null);
}
public static void save_temporal(Bitmap bitmap) {
File f3=new File(Environment.getExternalStorageDirectory()+"/inpaint/");
if(!f3.exists())
f3.mkdirs();
OutputStream outStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
outStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static Bitmap load_temporal() {
InputStream inStream;
inStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
inStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e(BitmapTools.LOG_TAG,e.getMessage());
}
Bitmap originalBitmap = BitmapFactory.decodeStream(inStream);
file.delete();
return originalBitmap ;
}
}
......@@ -62,4 +62,7 @@
android:launchMode="singleTop"
android:screenOrientation="landscape" />
</application>
</manifest>
......@@ -2,8 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
......@@ -11,14 +9,10 @@ import android.widget.RelativeLayout;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.MainActivity;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import com.yottacode.tools.BitmapTools;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static android.graphics.Color.argb;
......@@ -122,10 +116,11 @@ public class PictoMenu {
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
/*ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(IMAGE_PICTO, byteArray);
intent.putExtra(IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(bitmap);
intent.putExtra(IS_EDIT,true);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
......
......@@ -56,12 +56,12 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -393,6 +393,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override
protected void onPause() {
Log.e(this.LOG_TAG,"ONPAUSE");
super.onPause();
this.pictoCategoryGridAdapter.allPictosInGrid();
this.pictoMainGridAdapter.allPictosInGrid();
......@@ -408,6 +409,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override
protected void onDestroy() {
Log.e(LOG_TAG, "destroy Pictogram Activity");
super.onDestroy();
if (tts != null) {
tts.destroy();
......@@ -1215,11 +1217,11 @@ protected void showOnlyTape(boolean onlyTape) {
Intent intent = new Intent(this, EditPictoActivity.class);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
/* ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(image);
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
}
......
......@@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.media.MediaActionSound;
import android.media.MediaPlayer;
......@@ -33,7 +32,6 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;
......@@ -41,27 +39,25 @@ import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools;
import org.json.JSONException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import pl.droidsonroids.gif.GifTextView;
import static java.lang.Thread.sleep;
/**
......@@ -70,6 +66,7 @@ import static java.lang.Thread.sleep;
public class EditPictoActivity extends Activity {
private static final CharSequence NO_SUP_TEXT = "____________";
Picto p;
private boolean editar;
Random nRandom = new Random();
......@@ -101,8 +98,8 @@ public class EditPictoActivity extends Activity {
EditText legend;
//For Associated Supervisors/////////////////////////////////////////////////////////
Button desplegableSupervisores;
TextView supAsociado;
Button supAsociado;
private ListView mDrawerList;
private ArrayAdapter<String> mAdapter;
......@@ -253,7 +250,7 @@ public class EditPictoActivity extends Activity {
supervisoresAdapter.add(supervisor.get_name_sup()+", "+supervisor.get_surname_sup()+ "\n" +supervisor.get_email_sup() );
}
}
supervisoresAdapter.add(NO_SUP_TEXT+"\n"+NO_SUP_TEXT);
//String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
//Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
//ArrayList<String> supervisores = new ArrayList<>();
......@@ -328,8 +325,7 @@ public class EditPictoActivity extends Activity {
okButton = (Button) findViewById(R.id.okButton);
cancelButton = (Button) findViewById(R.id.cancelButton);
desplegableSupervisores = (Button) findViewById(R.id.botonDesplegable);
supAsociado = (TextView) findViewById(R.id.sup_actual);
supAsociado = (Button) findViewById(R.id.botonSupAsociado);//(TextView) findViewById(R.id.sup_actual);
botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar);
botonReproducir = (BotonCircular) findViewById(R.id.reproducir);
......@@ -366,16 +362,16 @@ public class EditPictoActivity extends Activity {
if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
legend.setText(p.get_translation());
supAsociado.setText(p.get_user_avatar());
supAsociado.setText(p.get_user_avatar()==null ? NO_SUP_TEXT : p.get_user_avatar());
}
legend.setHorizontallyScrolling(false);
legend.setMaxLines(1);
legend.setSingleLine(true);
//Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO);
final Bitmap imagePicto = scale_image(BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length));
/*byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO);*/
final Bitmap imagePicto = scale_image(BitmapTools.load_temporal());
cropImageView.setAspectRatio(editar ? imagePicto.getWidth() : 4,editar ? imagePicto.getHeight() : 3); //Si es editar un picto la ventana de recorte mantiene el tamaño de la imagen, sino 4:3
cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth());
......@@ -393,7 +389,7 @@ public class EditPictoActivity extends Activity {
//}
pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() {
supAsociado.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
......@@ -428,7 +424,7 @@ public class EditPictoActivity extends Activity {
String filepath = null;
String audioPath = null;
try {
id_pic = getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE);
id_pic = getIntent().getExtras()!=null ? getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE) : 0;
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
......@@ -478,7 +474,7 @@ public class EditPictoActivity extends Activity {
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText());
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText().equals(NO_SUP_TEXT)?null:supAsociado.getText());
//p.setUriSound(audioPath);
......@@ -706,10 +702,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(imagen);
cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
/*ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
}
break;
......@@ -726,10 +723,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(bitmap);
cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
/* ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
}
break;
}
......
......@@ -17,12 +17,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp"
android:paddingBottom="8dp"
android:paddingTop="@dimen/content_padding_half"
android:text="@string/titleCropperNew"
android:textAlignment="center"
android:textColor="@color/BlancoApp"
android:textSize="24sp" />
<LinearLayout
......@@ -109,34 +109,34 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="vertical">
<TextView
android:id="@+id/textAssociated"
android:id="@+id/textView_Supevisor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Asociar a:"
android:layout_marginTop="15dp"
android:text="Supervisor:"
android:textColor="@color/gray"
android:textSize="20sp" />
<Button
android:id="@+id/botonDesplegable"
android:id="@+id/botonSupAsociado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ver" />
android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp"
android:text="___________" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp"
/>
</LinearLayout>
<TextView
android:id="@+id/sup_actual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/textLegend"
......@@ -163,13 +163,21 @@
android:textColorLink="?android:attr/colorAccent"
android:textCursorDrawable="@null"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/VerdeApp"
android:paddingBottom="4dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
/>
<TextView
android:id="@+id/textView_Audio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Audio"
android:text="Audio:"
android:textColor="@color/gray"
android:textSize="20sp" />
......@@ -291,9 +299,13 @@
</LinearLayout>
</LinearLayout>
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp" />
</LinearLayout>
<LinearLayout
......@@ -335,6 +347,8 @@
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="right|end"
android:background="#ffeeeeee"/>
android:background="@color/VerdeApp"
android:headerDividersEnabled="false"
android:textColor="@color/BlancoApp" />
</android.support.v4.widget.DrawerLayout>
......@@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
......@@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......@@ -121,5 +121,17 @@
<orderEntry type="library" exported="" name="ion-2.1.9" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="module" module-name="commonlibrary" exported="" />
<orderEntry type="library" exported="" name="android-android-24" level="project" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
</component>
</module>
\ No newline at end of file
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