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
104367a8
authored
Mar 24, 2017
by
Germán Callejas Alcántara
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Rutas terminadas para almacenamiento en local
parent
2d86cc33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
29 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
104367a8
...
@@ -50,7 +50,7 @@ public class PictoUploader {
...
@@ -50,7 +50,7 @@ public class PictoUploader {
bmp
=
img
.
get_bitmap
(
PCBcontext
.
getContext
());
bmp
=
img
.
get_bitmap
(
PCBcontext
.
getContext
());
Log
.
i
(
LOG_TAG
,
"Uploading Picto img "
+
img
.
file_name
()
+
" from "
+
img
.
get_type
()
+
"- Size:"
+
bmp
.
getWidth
()
+
" "
+
bmp
.
getHeight
());
/*Log.i(LOG_TAG, "Uploading Picto img " + img.file_name() + " from " + img.get_type() + "- Size:" + bmp.getWidth() + " " + bmp.getHeight());*/
File
file
=
img
.
file
(
PCBcontext
.
getContext
());
File
file
=
img
.
file
(
PCBcontext
.
getContext
());
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
View file @
104367a8
...
@@ -41,6 +41,7 @@ import java.io.File;
...
@@ -41,6 +41,7 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Random
;
import
pl.droidsonroids.gif.GifTextView
;
import
pl.droidsonroids.gif.GifTextView
;
...
@@ -54,11 +55,12 @@ public class EditPictoActivity extends Activity {
...
@@ -54,11 +55,12 @@ public class EditPictoActivity extends Activity {
private
boolean
editar
;
private
boolean
editar
;
private
int
id_picto
;
private
int
id_picto
;
Random
nRandom
=
new
Random
();
int
pathNumber
;
private
static
final
int
CAMERA_PIC_REQUEST
=
1
;
private
static
final
int
CAMERA_PIC_REQUEST
=
1
;
private
static
final
int
GALLERY_PIC_REQUEST
=
2
;
private
static
final
int
GALLERY_PIC_REQUEST
=
2
;
p
rivate
static
final
String
DEBUG_MESSAGE
=
"TAG_PRUEBAS"
;
p
ublic
static
final
String
DEBUG_MESSAGE
=
"TAG_PRUEBAS"
;
public
static
final
int
EDIT_PICTO_REQUEST
=
2288
;
public
static
final
int
EDIT_PICTO_REQUEST
=
2288
;
public
static
final
int
FINISH_EDIT
=
2500
;
public
static
final
int
FINISH_EDIT
=
2500
;
...
@@ -76,7 +78,6 @@ public class EditPictoActivity extends Activity {
...
@@ -76,7 +78,6 @@ public class EditPictoActivity extends Activity {
public
static
final
String
PATH
=
"pathImage"
;
public
static
final
String
PATH
=
"pathImage"
;
public
static
final
String
IMAGE_PICTO
=
"imagePicto"
;
public
static
final
String
IMAGE_PICTO
=
"imagePicto"
;
private
static
final
String
LOG_PATH
=
EditPictoActivity
.
class
.
getName
();
//For Legend//////////////////////////////////////////////////////////////////////////
//For Legend//////////////////////////////////////////////////////////////////////////
EditText
legend
;
EditText
legend
;
...
@@ -154,7 +155,6 @@ public class EditPictoActivity extends Activity {
...
@@ -154,7 +155,6 @@ public class EditPictoActivity extends Activity {
if
(
tiempoGrabado
>
1
)
hayGrabacion
=
true
;
if
(
tiempoGrabado
>
1
)
hayGrabacion
=
true
;
else
hayGrabacion
=
false
;
else
hayGrabacion
=
false
;
reiniciarGrabacion
();
reiniciarGrabacion
();
//Log.i(DEBUG_MESSAGE,"Fin Grabacion..");
}
}
...
@@ -216,20 +216,14 @@ public class EditPictoActivity extends Activity {
...
@@ -216,20 +216,14 @@ public class EditPictoActivity extends Activity {
}
}
previewAudioPath
=
dirAudioPath
+
File
.
separator
+
"test.3gp"
;
previewAudioPath
=
dirAudioPath
+
File
.
separator
+
"test.3gp"
;
//Log.i(DEBUG_MESSAGE,"filepath"+filepath);
DisplayMetrics
metrics
=
new
DisplayMetrics
();
DisplayMetrics
metrics
=
new
DisplayMetrics
();
getWindowManager
().
getDefaultDisplay
().
getMetrics
(
metrics
);
getWindowManager
().
getDefaultDisplay
().
getMetrics
(
metrics
);
LinearLayout
ll
=
(
LinearLayout
)
findViewById
(
R
.
id
.
image_layout
);
LinearLayout
ll
=
(
LinearLayout
)
findViewById
(
R
.
id
.
image_layout
);
Log
.
i
(
"DETALLES"
,
"Tam menu imagen: "
+
ll
.
getLayoutParams
().
width
);
ll
.
getLayoutParams
().
width
=
(
int
)
(
metrics
.
widthPixels
*
0.65
)
-
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
activity_vertical_margin
)
*
2
;
ll
.
getLayoutParams
().
width
=
(
int
)
(
metrics
.
widthPixels
*
0.65
)
-
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
activity_vertical_margin
)
*
2
;
Log
.
i
(
"DETALLES"
,
"Tam menu imagen: "
+
ll
.
getLayoutParams
().
width
);
ll
.
requestLayout
();
ll
.
requestLayout
();
FrameLayout
fl
=
(
FrameLayout
)
findViewById
(
R
.
id
.
legend_menu
);
FrameLayout
fl
=
(
FrameLayout
)
findViewById
(
R
.
id
.
legend_menu
);
Log
.
i
(
"DETALLES"
,
"Tam menu leyenda: "
+
fl
.
getLayoutParams
().
width
);
fl
.
getLayoutParams
().
width
=
(
int
)
(
metrics
.
widthPixels
*
0.25
)
-
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
activity_vertical_margin
);
fl
.
getLayoutParams
().
width
=
(
int
)
(
metrics
.
widthPixels
*
0.25
)
-
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
activity_vertical_margin
);
Log
.
i
(
"DETALLES"
,
"Tam menu leyenda: "
+
fl
.
getLayoutParams
().
width
);
fl
.
requestLayout
();
fl
.
requestLayout
();
// Initialize Views.
// Initialize Views.
...
@@ -265,8 +259,6 @@ public class EditPictoActivity extends Activity {
...
@@ -265,8 +259,6 @@ public class EditPictoActivity extends Activity {
editar
=
getIntent
().
getBooleanExtra
(
"tipo"
,
false
);
editar
=
getIntent
().
getBooleanExtra
(
"tipo"
,
false
);
titulo
.
setText
(
editar
?
R
.
string
.
titleCropperEdit
:
R
.
string
.
titleCropperNew
);
titulo
.
setText
(
editar
?
R
.
string
.
titleCropperEdit
:
R
.
string
.
titleCropperNew
);
ActivityCompat
.
requestPermissions
(
this
,
permissions
,
REQUEST_RECORD_AUDIO_PERMISSION
);
ActivityCompat
.
requestPermissions
(
this
,
permissions
,
REQUEST_RECORD_AUDIO_PERMISSION
);
//Initialize elements and variables
//Initialize elements and variables
...
@@ -300,6 +292,7 @@ public class EditPictoActivity extends Activity {
...
@@ -300,6 +292,7 @@ public class EditPictoActivity extends Activity {
//layoutGrabacion.setVisibility(View.GONE);
//layoutGrabacion.setVisibility(View.GONE);
//layoutPreview.setVisibility(View.VISIBLE);
//layoutPreview.setVisibility(View.VISIBLE);
//}
//}
pathNumber
=
nRandom
.
nextInt
();
//Gestion de botones
//Gestion de botones
okButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
okButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
@@ -307,16 +300,22 @@ public class EditPictoActivity extends Activity {
...
@@ -307,16 +300,22 @@ public class EditPictoActivity extends Activity {
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
if
(
legend
.
getText
().
toString
().
trim
().
length
()
>
0
)
{
if
(
legend
.
getText
().
toString
().
trim
().
length
()
>
0
)
{
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
();
//Guardar imagen en galeria y obtener la ruta
//Guardar imagen en galeria y obtener la ruta
String
title
=
getResources
().
getString
(
R
.
string
.
app_name
)
+
' '
+
legend
.
getText
().
toString
();
try
{
try
{
id_picto
=
getIntent
().
getExtras
().
getInt
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
);
id_picto
=
getIntent
().
getExtras
().
getInt
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
);
String
filepath
=
dirImagePath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_"
+
id_picto
+
".png"
;
Log
.
i
(
DEBUG_MESSAGE
,
"filepath->"
+
filepath
);
String
filepath
=
editar
?
dirImagePath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_"
+
id_picto
+
".png"
:
dirImagePath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_new_"
+
pathNumber
+
".png"
;
File
imageFile
=
new
File
(
filepath
);
File
imageFile
=
new
File
(
filepath
);
if
(!
editar
)
{
//Si es añadir uno nuevo comprobar que el random no existe ya en el path
while
(
imageFile
.
exists
())
{
pathNumber
=
nRandom
.
nextInt
();
}
filepath
=
dirImagePath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_new_"
+
pathNumber
+
".png"
;
}
FileOutputStream
outputStream
=
new
FileOutputStream
(
imageFile
);
FileOutputStream
outputStream
=
new
FileOutputStream
(
imageFile
);
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
cropImageView
.
getCroppedImage
());
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
cropImageView
.
getCroppedImage
());
...
@@ -326,10 +325,10 @@ public class EditPictoActivity extends Activity {
...
@@ -326,10 +325,10 @@ public class EditPictoActivity extends Activity {
outputStream
.
close
();
outputStream
.
close
();
Intent
intent
=
getIntent
();
//Mandar a pictogram activity el path y el texto de la imagen
Intent
intent
=
getIntent
();
//Mandar a pictogram activity el path y el texto de la imagen
intent
.
putExtra
(
PATH
,
filepath
);
intent
.
putExtra
(
PATH
,
filepath
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
-
1
));
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
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
);
setResult
(
RESULT_OK
,
intent
);
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
...
@@ -338,18 +337,13 @@ public class EditPictoActivity extends Activity {
...
@@ -338,18 +337,13 @@ public class EditPictoActivity extends Activity {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
//String dirAudioPath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_MUSIC;
//dirAudioPath += "/PictoAudio";
//File dir = Environment.getExternalStorageDirectory();
Log
.
i
(
DEBUG_MESSAGE
,
String
.
valueOf
(
hayGrabacion
));
if
(
hayGrabacion
)
{
//Si ha grabado algo -> Ir a renombrarlo
if
(
hayGrabacion
)
{
//Si ha grabado algo -> Ir a renombrarlo
File
file
=
new
File
(
previewAudioPath
);
File
file
=
new
File
(
previewAudioPath
);
Log
.
i
(
DEBUG_MESSAGE
,
"Hay Grabacion -> Modifica nombre"
);
Log
.
i
(
DEBUG_MESSAGE
,
file
.
toString
());
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
File
from
=
new
File
(
previewAudioPath
);
File
from
=
new
File
(
previewAudioPath
);
File
to
=
new
File
(
dirAudioPath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_"
+
id_picto
+
"_audio.3gp"
);
File
to
=
new
File
(
editar
?
dirAudioPath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_"
+
id_picto
+
"_audio.3gp"
:
dirAudioPath
+
File
.
separator
+
legend
.
getText
().
toString
()
+
"_new_"
+
pathNumber
+
"_audio.3gp"
);
if
(
from
.
exists
())
if
(
from
.
exists
())
from
.
renameTo
(
to
);
from
.
renameTo
(
to
);
}
}
...
@@ -492,7 +486,6 @@ public class EditPictoActivity extends Activity {
...
@@ -492,7 +486,6 @@ public class EditPictoActivity extends Activity {
mRecorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
mRecorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
mRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
THREE_GPP
);
mRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
THREE_GPP
);
mRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AMR_NB
);
mRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AMR_NB
);
Log
.
i
(
DEBUG_MESSAGE
,
previewAudioPath
);
mRecorder
.
setOutputFile
(
previewAudioPath
);
mRecorder
.
setOutputFile
(
previewAudioPath
);
...
...
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