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
d7dfd909
authored
Feb 10, 2017
by
German Callejas
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Nueva forma para añadir pictos nuevos hecha (Arreglar tema del path, no lo crea el picto)
parent
3120a70c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
83 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/cropper/CropImageView.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/cropper/EditPictoActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
d7dfd909
...
...
@@ -2,6 +2,8 @@ package com.yottacode.pictogram.dao;
import
android.graphics.Color
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.util.Log
;
import
com.yottacode.pictogram.action.VocabularyAction
;
...
...
@@ -12,6 +14,8 @@ import com.yottacode.pictogram.tools.PCBcontext;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
/**
* A object which represents a pictogram
...
...
@@ -19,9 +23,7 @@ import org.json.JSONObject;
* @author Fernando Martinez Santiago
* @version 1.0
*/
public
class
Picto
extends
Img
{
public
class
Picto
extends
Img
{
public
final
static
class
JSON_ATTTRS
{
public
static
String
CATEGORY
=
"id_cat"
;
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/cropper/CropImageView.java
View file @
d7dfd909
...
...
@@ -253,10 +253,8 @@ public class CropImageView extends ImageView {
* Gets the cropped image based on the current crop window.
*
* @return a new Bitmap representing the cropped image
* @param origin
* @param orientation
*/
public
Bitmap
getCroppedImage
(
int
origin
,
int
orientation
)
{
public
Bitmap
getCroppedImage
()
{
final
Drawable
drawable
=
this
.
getDrawable
();
if
(
drawable
==
null
||
!(
drawable
instanceof
BitmapDrawable
))
{
return
null
;
...
...
@@ -271,8 +269,8 @@ public class CropImageView extends ImageView {
final
float
scaleY
=
matrixValues
[
Matrix
.
MSCALE_Y
];
//==1
// Extract the translation values.
final
float
transX
=
(
origin
==
CAMERA_PIC_REQUEST
&&
orientation
==
HORIZONTAL_ORIENTATION
)
?
matrixValues
[
Matrix
.
MTRANS_Y
]
:
matrixValues
[
Matrix
.
MTRANS_X
];
final
float
transY
=
(
origin
==
CAMERA_PIC_REQUEST
&&
orientation
==
HORIZONTAL_ORIENTATION
)
?
matrixValues
[
Matrix
.
MTRANS_X
]
:
matrixValues
[
Matrix
.
MTRANS_Y
];
final
float
transX
=
matrixValues
[
Matrix
.
MTRANS_X
];
final
float
transY
=
matrixValues
[
Matrix
.
MTRANS_Y
];
final
Bitmap
originalBitmap
=
((
BitmapDrawable
)
drawable
).
getBitmap
();
/*Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/cropper/EditPictoActivity.java
View file @
d7dfd909
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
cropper
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Color
;
import
android.media.effect.Effect
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.provider.MediaStore
;
import
android.text.InputType
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.Window
;
...
...
@@ -13,7 +19,16 @@ import android.widget.Button;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.grammar.Vocabulary
;
import
com.yottacode.pictogram.grammar.iLocalPicto
;
import
com.yottacode.pictogram.net.PictoUploader
;
import
com.yottacode.pictogram.tabletlibrary.R
;
import
com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
/**
* Created by German on 06/02/2017.
...
...
@@ -23,13 +38,14 @@ public class EditPictoActivity extends Activity {
// Private Constants ///////////////////////////////////////////////////////////////////////////
public
static
final
int
EDIT_PICTO_REQUEST
=
2288
;
public
static
final
int
UPLOAD_NEW_PICTO
=
200
;
public
static
final
String
TRANSCRIPTION
=
"textPicto"
;
public
static
final
String
PATH
=
"pathImage"
;
public
static
final
String
IMAGE_PICTO
=
"imagePicto"
;
public
static
final
String
IMAGE_ORIGIN
=
"imageOrigin"
;
public
static
final
String
IMAGE_ORIENTATION
=
"imageOrientation"
;
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -38,25 +54,20 @@ public class EditPictoActivity extends Activity {
setContentView
(
R
.
layout
.
edit_picto_layout
);
// Initialize Views.
final
CropImageView
cropImageView
=
(
CropImageView
)
findViewById
(
R
.
id
.
CropImageView
);
final
EditText
legend
=
(
EditText
)
findViewById
(
R
.
id
.
legend
);
final
Button
okButton
=
(
Button
)
findViewById
(
R
.
id
.
okButton
);
final
Button
cancelButton
=
(
Button
)
findViewById
(
R
.
id
.
cancelButton
);
//final ImageView backgroundImage = (ImageView) findViewById(R.id.backgroundImage);
cropImageView
.
setFixedAspectRatio
(
true
);
cropImageView
.
setGuidelines
(
2
);
cropImageView
.
setAspectRatio
(
1
,
1
);
final
int
orientation
=
getIntent
().
getExtras
().
getInt
(
EditPictoActivity
.
IMAGE_ORIENTATION
);
final
int
origin
=
getIntent
().
getExtras
().
getInt
(
EditPictoActivity
.
IMAGE_ORIGIN
);
//Obtener leyenda
String
legendText
=
getIntent
().
getExtras
().
getString
(
EditPictoActivity
.
TRANSCRIPTION
);
if
(
legendText
!=
null
)
{
Log
.
i
(
"DETALLES"
,
"Llega el intent al layout recortar, con texto: "
+
legendText
);
if
(
legendText
!=
null
)
{
//Si tenia leyenda(editarlo)
legend
.
setText
(
legendText
);
}
else
{
}
else
{
//Si no tenia el picto leyenda
legend
.
setTextColor
(
Color
.
GRAY
);
legend
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -65,27 +76,39 @@ public class EditPictoActivity extends Activity {
}
});
}
//Obtener imagen del intent
byte
[]
byteArray
=
getIntent
().
getByteArrayExtra
(
EditPictoActivity
.
IMAGE_PICTO
);
Bitmap
imagePicto
=
BitmapFactory
.
decodeByteArray
(
byteArray
,
0
,
byteArray
.
length
);
cropImageView
.
setImageBitmap
(
imagePicto
);
/*byteArray = getIntent().getByteArrayExtra("imageBackground");
Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
backgroundImage.setImageBitmap(imageBackground);*/
//Gestion de botones
okButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
(
origin
,
orientation
);
//Escalar y guardarla al server
Bitmap
finalImage
=
null
;
finalImage
.
createScaledBitmap
(
croppedImage
,
96
,
96
,
true
);
Intent
intent
=
getIntent
();
intent
.
putExtra
(
EditPictoActivity
.
TRANSCRIPTION
,
legend
.
getText
().
toString
());
Log
.
i
(
"DETALLES"
,
"sale el intent al layout recortar, con texto: "
+
legend
.
getText
().
toString
());
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
();
//Escalar imagen
Bitmap
finalImage
=
croppedImage
.
createScaledBitmap
(
croppedImage
,
96
,
96
,
true
);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream
bytes
=
new
ByteArrayOutputStream
();
finalImage
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bytes
);
String
path
=
MediaStore
.
Images
.
Media
.
insertImage
(
PCBcontext
.
getContext
().
getContentResolver
(),
finalImage
,
legend
.
getText
()+
"-recorte"
,
null
);
Uri
pathImage
=
Uri
.
parse
(
path
);
Intent
intent
=
new
Intent
(
EditPictoActivity
.
this
,
PictogramActivity
.
class
);
//Mandar a pictogram activity el path y el texto de la imagen
intent
.
putExtra
(
PATH
,
pathImage
.
toString
());
intent
.
putExtra
(
TRANSCRIPTION
,
legend
.
getText
().
toString
());
cropImageView
.
setImageBitmap
(
finalImage
);
setResult
(
RESULT_OK
,
intent
);
finish
();
finish
();
//Termina la actividad de editar
startActivityForResult
(
intent
,
UPLOAD_NEW_PICTO
);
//Llama a pictogramActivity de nuevo
//setResult(RESULT_OK,intent);
}
});
...
...
@@ -93,7 +116,9 @@ public class EditPictoActivity extends Activity {
cancelButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
EditPictoActivity
.
this
,
PictogramActivity
.
class
);
finish
();
startActivity
(
intent
);
}
});
}
...
...
@@ -125,6 +150,4 @@ public class EditPictoActivity extends Activity {
legend
.
setText
(
text
.
toString
());
}
}
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
View file @
d7dfd909
...
...
@@ -14,7 +14,6 @@ import android.widget.ArrayAdapter;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.Toast
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.grammar.Vocabulary
;
...
...
@@ -23,7 +22,6 @@ import com.yottacode.pictogram.net.PictoUploader;
import
com.yottacode.pictogram.tabletlibrary.R
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -58,7 +56,7 @@ public class PictoMenu {
* @param row
* @param col
*/
public
void
addPicto
(
int
row
,
int
col
)
{
public
void
addPicto
(
final
int
row
,
final
int
col
,
final
int
cat
)
{
final
String
[]
items
=
new
String
[]
{
activity
.
getString
(
R
.
string
.
dialogCamera
),
activity
.
getString
(
R
.
string
.
dialogGallery
)};
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
activity
,
android
.
R
.
layout
.
select_dialog_item
,
items
);
...
...
@@ -76,6 +74,17 @@ public class PictoMenu {
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
activity
.
startActivityForResult
(
intent
,
GALLERY_PIC_REQUEST
);
}
//Enviar al PictogramActivity los datos necesarios para crear el picto despues
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
{
activity
.
getIntent
().
putExtra
(
"cat"
,
cat
);
activity
.
getIntent
().
putExtra
(
Picto
.
JSON_ATTTRS
.
ROW
,
row
);
activity
.
getIntent
().
putExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
col
);
}
else
{
activity
.
getIntent
().
putExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
,
row
);
activity
.
getIntent
().
putExtra
(
Picto
.
JSON_ATTTRS
.
FREE_COLUMN
,
col
);
}
}
}
);
builder
.
setNegativeButton
(
activity
.
getString
(
R
.
string
.
dialogCancel
),
new
DialogInterface
.
OnClickListener
()
{
...
...
@@ -86,10 +95,11 @@ public class PictoMenu {
}
});
final
AlertDialog
dialog
=
builder
.
create
();
dialog
.
show
();
/*Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image*//*");
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
...
...
@@ -103,10 +113,11 @@ public class PictoMenu {
}
/**
* función para la edición de un texto asociado a una nueva imagen y guardar el nuevo picto
*/
public
void
chooseTextAndSavePicto
(
final
String
selectedImagePath
,
final
int
row
,
final
int
col
,
final
int
freeRow
,
final
int
freeColumn
)
{
/*
public void chooseTextAndSavePicto(final String selectedImagePath, final int row, final int col, final int freeRow, final int freeColumn) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(activity.getResources().getString(R.string.enterImgLabel));
...
...
@@ -121,8 +132,8 @@ public class PictoMenu {
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int
cat
=
activity
.
currentCategory
!=
null
?
activity
.
currentCategory
.
get_id
()
int cat = activity.
getCurrentCategory()
!= null
? activity.
getCurrentCategory()
.get_id()
: Picto.NO_CATEGORY;
PCBcontext.getVocabulary().saveLocalPicto(
selectedImagePath,
...
...
@@ -149,7 +160,7 @@ public class PictoMenu {
builder.show();
}
}
*/
/**
* Función para la selección de una foto del carrete
...
...
@@ -174,7 +185,7 @@ public class PictoMenu {
activity
.
getIntent
().
removeExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
);
activity
.
getIntent
().
removeExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
);
activity
.
getIntent
().
removeExtra
(
Picto
.
JSON_ATTTRS
.
FREE_COLUMN
);
chooseTextAndSavePicto
(
selectedImagePath
,
row
,
col
,
freeRow
,
freeColumn
);
//
chooseTextAndSavePicto(selectedImagePath, row, col, freeRow, freeColumn);
}
}
}
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
d7dfd909
This diff is collapsed.
Click to expand it.
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