Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
acd70e98
authored
Mar 22, 2017
by
Germán Callejas Alcántara
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Issue
#94
terminado
parent
3e63ab1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
15 deletions
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
View file @
acd70e98
...
...
@@ -3,6 +3,7 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
...
...
@@ -14,6 +15,7 @@ import android.media.MediaRecorder;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.ActivityCompat
;
...
...
@@ -44,7 +46,11 @@ import com.yottacode.pictogram.tools.PCBcontext;
import
com.yottacode.tools.GUITools
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectOutputStream
;
import
pl.droidsonroids.gif.GifTextView
;
...
...
@@ -250,24 +256,35 @@ public class EditPictoActivity extends Activity {
if
(
legend
.
getText
().
toString
().
trim
().
length
()
>
0
)
{
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
();
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream
bytes
=
new
ByteArrayOutputStream
();
croppedImage
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
bytes
);
String
title
=
getResources
().
getString
(
R
.
string
.
app_name
)
+
' '
+
legend
.
getText
().
toString
();
String
path
=
MediaStore
.
Images
.
Media
.
insertImage
(
getContentResolver
(),
croppedImage
,
title
,
null
);
path
=
getRealPathFromURI
(
Uri
.
parse
(
path
));
Log
.
i
(
LOG_PATH
,
" New image "
+
title
+
" saved at "
+
path
);
Intent
intent
=
getIntent
();
//Mandar a pictogram activity el path y el texto de la imagen
intent
.
putExtra
(
PATH
,
path
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
-
1
));
intent
.
putExtra
(
"tipo"
,
editar
);
//Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
setResult
(
RESULT_OK
,
intent
);
cropImageView
.
setImageBitmap
(
croppedImage
);
try
{
String
title
=
getResources
().
getString
(
R
.
string
.
app_name
)
+
' '
+
legend
.
getText
().
toString
();
String
path
=
"/storage/emulated/0/DCIM/Camera/"
+
title
+
".png"
;
File
imageFile
=
new
File
(
path
);
FileOutputStream
outputStream
=
new
FileOutputStream
(
imageFile
);
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
cropImageView
.
getCroppedImage
());
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
90
,
outputStream
);
MediaStore
.
Images
.
Media
.
insertImage
(
getContentResolver
(),
bitmap
,
path
,
null
);
outputStream
.
flush
();
outputStream
.
close
();
Intent
intent
=
getIntent
();
//Mandar a pictogram activity el path y el texto de la imagen
intent
.
putExtra
(
PATH
,
path
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
-
1
));
intent
.
putExtra
(
"tipo"
,
editar
);
//Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
setResult
(
RESULT_OK
,
intent
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finish
();
//Termina la actividad de editar
}
else
Toast
.
makeText
(
getBaseContext
(),
R
.
string
.
crop_TextRequired
,
Toast
.
LENGTH_LONG
).
show
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment