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
a3d95466
authored
Mar 17, 2017
by
Germán Callejas Alcántara
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Añadida a la vista de editar picto el layout para realizar grabaciones (Falta pulir)
parent
29a221a0
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
960 additions
and
112 deletions
android/Pictogram/tabletlibrary/src/main/AndroidManifest.xml
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/BotonCircular.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/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/micro.png
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/photo_camera.png
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/photo_gallery.png
android/Pictogram/tabletlibrary/src/main/res/drawable/editpicto_edittext_style.xml
android/Pictogram/tabletlibrary/src/main/res/layout/edit_picto_layout.xml
android/Pictogram/tabletlibrary/src/main/res/values-en/strings.xml
android/Pictogram/tabletlibrary/src/main/res/values-es/strings.xml
android/Pictogram/tabletlibrary/src/main/res/values/strings.xml
android/Pictogram/tabletlibrary/tabletlibrary.iml
android/Pictogram/tabletlibrary/src/main/AndroidManifest.xml
View file @
a3d95466
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.yottacode.pictogram.tabletlibrary"
>
package=
"com.yottacode.pictogram.tabletlibrary"
>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
<application
<application
android:allowBackup=
"true"
android:allowBackup=
"true"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/BotonCircular.java
0 → 100644
View file @
a3d95466
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
com.yottacode.pictogram.tabletlibrary.R
;
import
android.animation.ObjectAnimator
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.support.annotation.ColorRes
;
import
android.util.AttributeSet
;
import
android.util.TypedValue
;
import
android.widget.ImageView
;
public
class
BotonCircular
extends
android
.
support
.
v7
.
widget
.
AppCompatImageView
{
private
static
final
int
PRESSED_COLOR_LIGHTUP
=
255
/
25
;
private
static
final
int
PRESSED_RING_ALPHA
=
75
;
private
static
final
int
DEFAULT_PRESSED_RING_WIDTH_DIP
=
4
;
private
static
final
int
ANIMATION_TIME_ID
=
android
.
R
.
integer
.
config_shortAnimTime
;
private
int
centerY
;
private
int
centerX
;
private
int
outerRadius
;
private
int
pressedRingRadius
;
private
Paint
circlePaint
;
private
Paint
focusPaint
;
private
float
animationProgress
;
private
int
pressedRingWidth
;
private
int
defaultColor
;
private
int
pressedColor
;
private
ObjectAnimator
pressedAnimator
;
public
BotonCircular
(
Context
context
)
{
super
(
context
);
init
(
context
,
null
);
}
public
BotonCircular
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
(
context
,
attrs
);
}
public
BotonCircular
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
init
(
context
,
attrs
);
}
@Override
public
void
setPressed
(
boolean
pressed
)
{
super
.
setPressed
(
pressed
);
if
(
circlePaint
!=
null
)
{
circlePaint
.
setColor
(
pressed
?
pressedColor
:
defaultColor
);
}
if
(
pressed
)
{
showPressedRing
();
}
else
{
hidePressedRing
();
}
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
canvas
.
drawCircle
(
centerX
,
centerY
,
pressedRingRadius
+
animationProgress
,
focusPaint
);
canvas
.
drawCircle
(
centerX
,
centerY
,
outerRadius
-
pressedRingWidth
,
circlePaint
);
super
.
onDraw
(
canvas
);
}
@Override
protected
void
onSizeChanged
(
int
w
,
int
h
,
int
oldw
,
int
oldh
)
{
super
.
onSizeChanged
(
w
,
h
,
oldw
,
oldh
);
centerX
=
w
/
2
;
centerY
=
h
/
2
;
outerRadius
=
Math
.
min
(
w
,
h
)
/
2
;
pressedRingRadius
=
outerRadius
-
pressedRingWidth
-
pressedRingWidth
/
2
;
}
public
float
getAnimationProgress
()
{
return
animationProgress
;
}
public
void
setAnimationProgress
(
float
animationProgress
)
{
this
.
animationProgress
=
animationProgress
;
this
.
invalidate
();
}
public
void
setColor
(
int
color
)
{
this
.
defaultColor
=
color
;
this
.
pressedColor
=
getHighlightColor
(
color
,
PRESSED_COLOR_LIGHTUP
);
circlePaint
.
setColor
(
defaultColor
);
focusPaint
.
setColor
(
pressedColor
);
focusPaint
.
setAlpha
(
PRESSED_RING_ALPHA
);
this
.
invalidate
();
}
/**Esconder anillo exterior animacion*/
private
void
hidePressedRing
()
{
pressedAnimator
.
setFloatValues
(
pressedRingWidth
,
0
f
);
pressedAnimator
.
start
();
}
public
void
PhidePressedRing
()
{
pressedAnimator
.
setFloatValues
(
pressedRingWidth
,
0
f
);
pressedAnimator
.
start
();
}
/**Mostrar anillo exterior animacion*/
private
void
showPressedRing
()
{
pressedAnimator
.
setFloatValues
(
animationProgress
,
pressedRingWidth
);
pressedAnimator
.
start
();
}
public
void
PshowPressedRing
()
{
pressedAnimator
.
setFloatValues
(
animationProgress
,
pressedRingWidth
);
pressedAnimator
.
start
();
}
private
void
init
(
Context
context
,
AttributeSet
attrs
)
{
this
.
setFocusable
(
true
);
this
.
setScaleType
(
ScaleType
.
CENTER_INSIDE
);
setClickable
(
true
);
circlePaint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
circlePaint
.
setStyle
(
Paint
.
Style
.
FILL
);
focusPaint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
focusPaint
.
setStyle
(
Paint
.
Style
.
STROKE
);
pressedRingWidth
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
DEFAULT_PRESSED_RING_WIDTH_DIP
,
getResources
()
.
getDisplayMetrics
());
//int color = Color.rgb(106, 142, 26);
/*if (attrs != null) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleButton);
color = a.getColor(R.styleable.CircleButton_cb_color, color);
pressedRingWidth = (int) a.getDimension(R.styleable.CircleButton_cb_pressedRingWidth, pressedRingWidth);
a.recycle();
}*/
int
color
=
getResources
().
getColor
(
R
.
color
.
VerdeApp
);
setColor
(
color
);
focusPaint
.
setStrokeWidth
(
pressedRingWidth
);
final
int
pressedAnimationTime
=
getResources
().
getInteger
(
ANIMATION_TIME_ID
);
pressedAnimator
=
ObjectAnimator
.
ofFloat
(
this
,
"animationProgress"
,
0
f
,
0
f
);
pressedAnimator
.
setDuration
(
pressedAnimationTime
);
}
private
int
getHighlightColor
(
int
color
,
int
amount
)
{
return
Color
.
argb
(
Math
.
min
(
255
,
Color
.
alpha
(
color
)),
Math
.
min
(
255
,
Color
.
red
(
color
)
+
amount
),
Math
.
min
(
255
,
Color
.
green
(
color
)
+
amount
),
Math
.
min
(
255
,
Color
.
blue
(
color
)
+
amount
));
}
}
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
View file @
a3d95466
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Point
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.tabletlibrary.R
;
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.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.GUITools
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -100,6 +106,42 @@ public class PictoMenu {
...
@@ -100,6 +106,42 @@ public class PictoMenu {
}
}
public
void
setPicto
(
int
row
,
int
col
,
int
cat
,
String
expression
,
Bitmap
bitmap
){
Intent
intent
=
new
Intent
(
activity
,
EditPictoActivity
.
class
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
expression
);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
{
intent
.
putExtra
(
"cat"
,
cat
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
ROW
,
row
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
col
);
}
else
{
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
,
row
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
FREE_COLUMN
,
col
);
}
if
(
bitmap
!=
null
)
{
Point
size
=
GUITools
.
getScreenSize
(
activity
);
float
bWidth
=
bitmap
.
getWidth
();
float
bHeight
=
bitmap
.
getHeight
();
float
factorX
=
size
.
x
*
0.7f
/
bWidth
;
float
factorY
=
size
.
y
*
0.7f
/
bHeight
;
float
factor
=
factorY
>
factorX
?
factorX
:
factorY
;
bWidth
=
bWidth
*
factor
;
bHeight
=
bHeight
*
factor
;
Bitmap
rescaled
=
Bitmap
.
createScaledBitmap
(
bitmap
,(
int
)
bWidth
,
(
int
)
bHeight
,
true
);
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
rescaled
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
byte
[]
byteArray
=
stream
.
toByteArray
();
intent
.
putExtra
(
EditPictoActivity
.
IMAGE_PICTO
,
byteArray
);
}
intent
.
putExtra
(
"tipo"
,
true
);
activity
.
startActivity
(
intent
);
}
/**Function for build a radial menu
/**Function for build a radial menu
*
*
* @param is_picto_big
* @param is_picto_big
...
@@ -245,21 +287,29 @@ public class PictoMenu {
...
@@ -245,21 +287,29 @@ public class PictoMenu {
}
}
public
String
getName
()
{
return
"edit"
;
}
public
String
getName
()
{
return
"edit"
;
}
public
String
getLabel
()
{
return
null
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
edit
_picture
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
edit
;
}
private
List
<
RadialMenuWidget
.
RadialMenuEntry
>
children
;
private
List
<
RadialMenuWidget
.
RadialMenuEntry
>
children
;
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
children
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
children
;
}
public
void
menuActiviated
()
public
void
menuActiviated
()
{
{
ll
.
getChildAt
(
1
).
setX
(
ll
.
getChildAt
(
1
).
getX
()
+
30
);
ll
.
setVisibility
(
View
.
GONE
);
children
=
new
ArrayList
<>(
Arrays
.
asList
(
new
PickFromCamera
(
p
),
new
PickFromGallery
(
p
)));
ll
.
removeAllViewsInLayout
();
try
{
setPicto
(
p
.
get_row
(),
p
.
get_column
(),
p
.
get_category
(),
p
.
get_translation
(),
p
.
get_bitmap
(
PCBcontext
.
getContext
()));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
//ll.getChildAt(1).setX(ll.getChildAt(1).getX() + 30);
//children = new ArrayList<>(Arrays.asList(new PickFromCamera(p),new PickFromGallery(p)));
}
}
public
void
menuDisabled
(){
public
void
menuDisabled
(){
ll
.
getChildAt
(
1
).
setX
(
ll
.
getChildAt
(
1
).
getX
()
-
30
);
//
ll.getChildAt(1).setX(ll.getChildAt(1).getX() - 30);
}
}
}
}
public
class
PickFromCamera
implements
RadialMenuWidget
.
RadialMenuEntry
/*
public class PickFromCamera implements RadialMenuWidget.RadialMenuEntry
{
{
Picto p;
Picto p;
public PickFromCamera(Picto picto){
public PickFromCamera(Picto picto){
...
@@ -296,7 +346,7 @@ public class PictoMenu {
...
@@ -296,7 +346,7 @@ public class PictoMenu {
addPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),1);
addPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),1);
}
}
public void menuDisabled(){}
public void menuDisabled(){}
}
}
*/
public
class
newPickFromCamera
implements
RadialMenuWidget
.
RadialMenuEntry
public
class
newPickFromCamera
implements
RadialMenuWidget
.
RadialMenuEntry
{
{
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
a3d95466
...
@@ -1151,6 +1151,7 @@ protected void showOnlyTape(boolean onlyTape) {
...
@@ -1151,6 +1151,7 @@ protected void showOnlyTape(boolean onlyTape) {
break
;
break
;
case
EditPictoActivity
.
EDIT_PICTO_REQUEST
:
case
EditPictoActivity
.
EDIT_PICTO_REQUEST
:
if
(
resultCode
==
RESULT_OK
)
{
if
(
resultCode
==
RESULT_OK
)
{
Log
.
i
(
"TAG_PRUEBAS"
,
"Llega a fin de nuevo"
);
int
row
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
ROW
,
-
1
);
int
row
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
ROW
,
-
1
);
int
col
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
-
1
);
int
col
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
-
1
);
int
freeRow
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
,
-
1
);
int
freeRow
=
getIntent
().
getIntExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
,
-
1
);
...
@@ -1161,6 +1162,17 @@ protected void showOnlyTape(boolean onlyTape) {
...
@@ -1161,6 +1162,17 @@ protected void showOnlyTape(boolean onlyTape) {
chooseTextAndSavePicto
(
path
,
row
,
col
,
freeRow
,
freeColumn
,
cat
,
legend
);
chooseTextAndSavePicto
(
path
,
row
,
col
,
freeRow
,
freeColumn
,
cat
,
legend
);
}
}
break
;
break
;
case
EditPictoActivity
.
FINISH_EDIT
:
Log
.
i
(
"TAG_PRUEBAS"
,
"Llega a fin de editar"
);
int
row
=
data
.
getIntExtra
(
Picto
.
JSON_ATTTRS
.
ROW
,
-
1
);
int
col
=
data
.
getIntExtra
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
-
1
);
int
freeRow
=
data
.
getIntExtra
(
Picto
.
JSON_ATTTRS
.
FREE_ROW
,
-
1
);
int
freeColumn
=
data
.
getIntExtra
(
Picto
.
JSON_ATTTRS
.
FREE_COLUMN
,
-
1
);
String
path
=
data
.
getExtras
().
getString
(
EditPictoActivity
.
PATH
);
String
legend
=
data
.
getExtras
().
getString
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
);
chooseTextAndSavePicto
(
path
,
row
,
col
,
freeRow
,
freeColumn
,
cat
,
legend
);
break
;
}
}
}
}
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
View file @
a3d95466
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
.
cropper
;
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
.
cropper
;
import
android.Manifest
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.ContentValues
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Point
;
import
android.media.MediaPlayer
;
import
android.media.MediaRecorder
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.ActivityCompat
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.Window
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.yottacode.pictogram.dao.Picto
;
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.R
;
import
com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
;
import
com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity
;
import
com.yottacode.pictogram.tabletlibrary.gui.login.MainActivity
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.GUITools
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
static
java
.
lang
.
Thread
.
sleep
;
/**
/**
* Created by German on 06/02/2017.
* Created by German on 06/02/2017.
*/
*/
public
class
EditPictoActivity
extends
Activity
{
public
class
EditPictoActivity
extends
Activity
{
// Private Constants ///////////////////////////////////////////////////////////////////////////
private
boolean
editar
;
private
static
final
int
CAMERA_PIC_REQUEST
=
1
;
private
static
final
int
GALLERY_PIC_REQUEST
=
2
;
private
static
final
String
DEBUG_MESSAGE
=
"Pruebas"
;
public
static
final
int
EDIT_PICTO_REQUEST
=
2288
;
public
static
final
int
EDIT_PICTO_REQUEST
=
2288
;
public
static
final
int
FINISH_EDIT
=
2500
;
//Botones Final/////////////////////////////////////////////////////////////////////
Button
okButton
;
Button
cancelButton
;
//Titulo//////////////////////////////////////////////////////////////////////////////
TextView
titulo
;
//For Cropper/////////////////////////////////////////////////////////////////////////
CropImageView
cropImageView
;
BotonCircular
camara
;
BotonCircular
galeria
;
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
();
private
static
final
String
LOG_PATH
=
EditPictoActivity
.
class
.
getName
();
//For Legend//////////////////////////////////////////////////////////////////////////
EditText
legend
;
//For Audio///////////////////////////////////////////////////////////////////////////
private
static
final
int
REQUEST_RECORD_AUDIO_PERMISSION
=
200
;
private
static
String
mFileName
=
null
;
private
MediaRecorder
mRecorder
=
null
;
private
MediaPlayer
mPlayer
=
null
;
BotonCircular
botonGrabar
;
BotonCircular
botonReproducir
;
BotonCircular
botonBorrar
;
SeekBar
barraReproducir
;
TextView
textoTTotal
;
TextView
textoTGrabacion
;
LinearLayout
layoutPreview
;
LinearLayout
layoutGrabacion
;
RecordTask
tareaGrabacion
;
PlayTask
tareaReproduccion
;
//boolean grabando;
boolean
reproduciendo
;
int
tiempoGrabado
;
int
tiempoReproducir
;
int
tiempoTotal
;
// Requesting permission to RECORD_AUDIO
private
boolean
permissionToRecordAccepted
=
false
;
private
String
[]
permissions
=
{
Manifest
.
permission
.
RECORD_AUDIO
};
/**
* Tarea para gestionar tiempo de grabacion
*/
private
class
RecordTask
extends
AsyncTask
<
Integer
,
Integer
,
Void
>
{
protected
Void
doInBackground
(
Integer
...
params
)
{
while
(!
isCancelled
()
&&
tiempoGrabado
<
10
){
publishProgress
(
tiempoGrabado
);
try
{
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
this
.
cancel
(
true
);
return
null
;
}
protected
void
onProgressUpdate
(
Integer
...
progress
)
{
textoTGrabacion
.
setText
(
"00:"
+
(
tiempoGrabado
==
10
?
tiempoGrabado
:
"0"
+
tiempoGrabado
)+
" | 00:10"
);
botonGrabar
.
PshowPressedRing
();
tiempoGrabado
+=
1
;
}
protected
void
onCancelled
(){
stopRecording
();
botonReproducir
.
setEnabled
(
tiempoGrabado
>
1
?
true
:
false
);
layoutPreview
.
setVisibility
(
tiempoGrabado
>
1
?
View
.
VISIBLE
:
View
.
GONE
);
layoutGrabacion
.
setVisibility
(
tiempoGrabado
>
1
?
View
.
GONE
:
View
.
VISIBLE
);
textoTTotal
.
setText
(
tiempoGrabado
==
10
?
"00:00 | 00:"
+
tiempoGrabado
:
"00:00 | 00:0"
+
tiempoGrabado
);
tiempoTotal
=
tiempoGrabado
-
1
;
barraReproducir
.
setMax
(
tiempoTotal
);
botonGrabar
.
PhidePressedRing
();
reiniciarGrabacion
();
Log
.
i
(
DEBUG_MESSAGE
,
"Fin Grabacion.."
);
}
}
/**
* Tarea para gestionar barra y tiempo de reproducion
*/
private
class
PlayTask
extends
AsyncTask
<
Integer
,
Integer
,
Void
>
{
protected
Void
doInBackground
(
Integer
...
params
)
{
while
(!
isCancelled
()
&&
tiempoReproducir
<
tiempoTotal
){
try
{
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
publishProgress
(
tiempoReproducir
);
}
this
.
cancel
(
true
);
return
null
;
}
protected
void
onProgressUpdate
(
Integer
...
progress
)
{
tiempoReproducir
+=
1
;
barraReproducir
.
setProgress
(
tiempoReproducir
);
textoTTotal
.
setText
(
tiempoReproducir
==
10
?
(
"00:"
+
tiempoReproducir
+
" | 00:"
+
(
tiempoTotal
==
10
?
tiempoTotal
:
(
"0"
+
tiempoTotal
)))
:
(
"00:0"
+
tiempoReproducir
+
" | 00:"
+(
tiempoTotal
==
10
?
tiempoTotal:
(
"0"
+
tiempoTotal
))));
}
protected
void
onCancelled
(){
stopPlaying
();
reiniciarReproducci
ó
n
();
Log
.
i
(
DEBUG_MESSAGE
,
"Fin Reproducion.."
);
}
}
// Activity Methods ////////////////////////////////////////////////////////////////////////////
// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -44,37 +189,34 @@ public class EditPictoActivity extends Activity {
...
@@ -44,37 +189,34 @@ public class EditPictoActivity extends Activity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
edit_picto_layout
);
setContentView
(
R
.
layout
.
edit_picto_layout
);
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
);
Log
.
i
(
"DETALLES"
,
"Tam menu imagen: "
+
ll
.
getLayoutParams
().
width
);
ll
.
getLayoutParams
().
width
=
(
int
)
(
metrics
.
widthPixels
*
0.
75
)
-
(
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
);
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
);
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
);
Log
.
i
(
"DETALLES"
,
"Tam menu leyenda: "
+
fl
.
getLayoutParams
().
width
);
fl
.
requestLayout
();
fl
.
requestLayout
();
// Initialize Views.
// Initialize Views.
final
CropImageView
cropImageView
=
(
CropImageView
)
findViewById
(
R
.
id
.
CropImageView
);
titulo
=
(
TextView
)
findViewById
(
R
.
id
.
crop_title
);
final
EditText
legend
=
(
EditText
)
findViewById
(
R
.
id
.
edtLegend
);
cropImageView
=
(
CropImageView
)
findViewById
(
R
.
id
.
CropImageView
);
final
Button
okButton
=
(
Button
)
findViewById
(
R
.
id
.
okButton
);
legend
=
(
EditText
)
findViewById
(
R
.
id
.
edtLegend
);
final
Button
cancelButton
=
(
Button
)
findViewById
(
R
.
id
.
cancelButton
);
okButton
=
(
Button
)
findViewById
(
R
.
id
.
okButton
);
String
transcription
=
getIntent
().
getExtras
().
getString
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
);
cancelButton
=
(
Button
)
findViewById
(
R
.
id
.
cancelButton
);
String
transcription
=
getIntent
().
getExtras
().
getString
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
);
cropImageView
.
setFixedAspectRatio
(
true
);
cropImageView
.
setFixedAspectRatio
(
true
);
cropImageView
.
setGuidelines
(
2
);
cropImageView
.
setGuidelines
(
2
);
cropImageView
.
setAspectRatio
(
1
,
1
);
cropImageView
.
setAspectRatio
(
1
,
1
);
if
(
transcription
!=
null
&&
transcription
.
length
()>
0
)
if
(
transcription
!=
null
&&
transcription
.
length
()
>
0
)
legend
.
setText
(
transcription
);
legend
.
setText
(
transcription
);
legend
.
setHorizontallyScrolling
(
false
);
legend
.
setHorizontallyScrolling
(
false
);
legend
.
setMaxLines
(
1
);
legend
.
setMaxLines
(
1
);
...
@@ -86,34 +228,53 @@ public class EditPictoActivity extends Activity {
...
@@ -86,34 +228,53 @@ public class EditPictoActivity extends Activity {
cropImageView
.
setImageBitmap
(
imagePicto
);
cropImageView
.
setImageBitmap
(
imagePicto
);
cropImageView
.
setMaxWidth
(
imagePicto
.
getWidth
());
cropImageView
.
setMaxWidth
(
imagePicto
.
getWidth
());
cropImageView
.
setMaxHeight
(
imagePicto
.
getHeight
());
cropImageView
.
setMaxHeight
(
imagePicto
.
getHeight
());
if
(
transcription
!=
null
&&
transcription
.
length
()>
0
)
if
(
transcription
!=
null
&&
transcription
.
length
()
>
0
)
legend
.
setText
(
transcription
);
legend
.
setText
(
transcription
);
editar
=
getIntent
().
getBooleanExtra
(
"tipo"
,
false
);
titulo
.
setText
(
editar
?
R
.
string
.
titleCropperEdit
:
R
.
string
.
titleCropperNew
);
//Gestion de botones
//Gestion de botones
okButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
okButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
if
(
legend
.
getText
().
toString
().
trim
().
length
()>
0
)
{
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
();
if
(
legend
.
getText
().
toString
().
trim
().
length
()
>
0
)
{
//Escalar imagen
final
Bitmap
croppedImage
=
cropImageView
.
getCroppedImage
();
Bitmap
finalImage
=
croppedImage
.
createScaledBitmap
(
croppedImage
,
96
,
96
,
true
);
//Escalar imagen
Bitmap
finalImage
=
croppedImage
.
createScaledBitmap
(
croppedImage
,
100
,
100
,
true
);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream
bytes
=
new
ByteArrayOutputStream
();
//Guardar imagen en galeria y obtener la ruta
finalImage
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bytes
);
ByteArrayOutputStream
bytes
=
new
ByteArrayOutputStream
();
String
title
=
getResources
().
getString
(
R
.
string
.
app_name
)
+
' '
+
legend
.
getText
().
toString
();
finalImage
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bytes
);
String
path
=
MediaStore
.
Images
.
Media
.
insertImage
(
PCBcontext
.
getContext
().
getContentResolver
(),
finalImage
,
title
,
null
);
String
title
=
getResources
().
getString
(
R
.
string
.
app_name
)
+
' '
+
legend
.
getText
().
toString
();
path
=
getRealPathFromURI
(
Uri
.
parse
(
path
));
String
path
=
MediaStore
.
Images
.
Media
.
insertImage
(
PCBcontext
.
getContext
().
getContentResolver
(),
finalImage
,
title
,
null
);
Log
.
i
(
LOG_PATH
,
" New image "
+
title
+
" saved at "
+
path
);
path
=
getRealPathFromURI
(
Uri
.
parse
(
path
));
Intent
intent
=
getIntent
();
//Mandar a pictogram activity el path y el texto de la imagen
Log
.
i
(
LOG_PATH
,
" New image "
+
title
+
" saved at "
+
path
);
intent
.
putExtra
(
PATH
,
path
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
//Intent intent = new Intent(EditPictoActivity.this,PictogramActivity.class);//getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
//intent.putExtra(PATH, path);
cropImageView
.
setImageBitmap
(
finalImage
);
//intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString());
setResult
(
RESULT_OK
,
intent
);
finish
();
//Termina la actividad de editar
cropImageView
.
setImageBitmap
(
finalImage
);
}
if
(
editar
){
else
Toast
.
makeText
(
getBaseContext
(),
R
.
string
.
crop_TextRequired
,
Toast
.
LENGTH_LONG
).
show
();
Log
.
i
(
"TAG_PRUEBAS"
,
"Lanza ok de editar"
);
//Intent intent = new Intent(EditPictoActivity.this,PictogramActivity.class);//Mandar a pictogram activity el path y el texto de la imagen
Intent
intent
=
getIntent
();
intent
.
putExtra
(
PATH
,
path
);
intent
.
putExtra
(
Picto
.
JSON_ATTTRS
.
EXPRESSION
,
legend
.
getText
().
toString
());
intent
.
setAction
(
String
.
valueOf
(
FINISH_EDIT
));
//startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
}
else
{
Log
.
i
(
"TAG_PRUEBAS"
,
"Lanza ok de nuevo"
);
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
());
setResult
(
RESULT_OK
,
intent
);
}
finish
();
//Termina la actividad de editar
}
else
Toast
.
makeText
(
getBaseContext
(),
R
.
string
.
crop_TextRequired
,
Toast
.
LENGTH_LONG
).
show
();
}
}
});
});
...
@@ -122,7 +283,114 @@ public class EditPictoActivity extends Activity {
...
@@ -122,7 +283,114 @@ public class EditPictoActivity extends Activity {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
finish
();
finish
();
setResult
(
RESULT_CANCELED
,
getIntent
());
setResult
(
RESULT_CANCELED
,
getIntent
());
}
});
// Record to the external cache directory for visibility
mFileName
=
getFilesDir
().
getPath
();
mFileName
+=
"/audiorecordtest.3gp"
;
ContentValues
values
=
new
ContentValues
(
3
);
values
.
put
(
MediaStore
.
MediaColumns
.
TITLE
,
mFileName
);
ActivityCompat
.
requestPermissions
(
this
,
permissions
,
REQUEST_RECORD_AUDIO_PERMISSION
);
//Initialize elements and variables
botonGrabar
=
(
BotonCircular
)
findViewById
(
R
.
id
.
botonGrabar
);
botonReproducir
=
(
BotonCircular
)
findViewById
(
R
.
id
.
reproducir
);
botonBorrar
=
(
BotonCircular
)
findViewById
(
R
.
id
.
botonBorrar
);
camara
=
(
BotonCircular
)
findViewById
(
R
.
id
.
camara
);
galeria
=
(
BotonCircular
)
findViewById
(
R
.
id
.
galeria
);
barraReproducir
=
(
SeekBar
)
findViewById
(
R
.
id
.
barraReproducir
);
textoTTotal
=
(
TextView
)
findViewById
(
R
.
id
.
tiempoTotal
);
textoTGrabacion
=
(
TextView
)
findViewById
(
R
.
id
.
tiempoActual
);
layoutPreview
=
(
LinearLayout
)
findViewById
(
R
.
id
.
layoutPreview
);
layoutGrabacion
=
(
LinearLayout
)
findViewById
(
R
.
id
.
layout_record
);
botonReproducir
.
setEnabled
(
false
);
layoutPreview
.
setVisibility
(
View
.
INVISIBLE
);
reproduciendo
=
false
;
tiempoGrabado
=
0
;
tiempoReproducir
=
0
;
tiempoTotal
=
0
;
//TODO: Aqui comprobar si ya hay grabación
//if (hayGrabacion){
layoutGrabacion
.
setVisibility
(
View
.
VISIBLE
);
layoutPreview
.
setVisibility
(
View
.
GONE
);
//}else{ Cargar el audio en el mediaPlayer
//layoutGrabacion.setVisibility(View.GONE);
//layoutPreview.setVisibility(View.VISIBLE);
//}
botonGrabar
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
switch
(
event
.
getAction
()){
case
MotionEvent
.
ACTION_DOWN
:
tareaGrabacion
=
(
RecordTask
)
new
RecordTask
().
execute
(
tiempoGrabado
);
startRecording
();
Log
.
i
(
DEBUG_MESSAGE
,
"Grabando.."
);
return
true
;
case
MotionEvent
.
ACTION_UP
:
tareaGrabacion
.
cancel
(
true
);
return
true
;
}
return
false
;
}
});
botonReproducir
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
reproduciendo
){
tareaReproduccion
.
cancel
(
true
);
reproduciendo
=
false
;
Log
.
i
(
DEBUG_MESSAGE
,
"parar"
);
botonReproducir
.
setImageResource
(
android
.
R
.
drawable
.
ic_media_play
);
}
else
{
reproduciendo
=
true
;
startPlaying
();
Log
.
i
(
DEBUG_MESSAGE
,
"Reproducir"
);
tareaReproduccion
=
(
PlayTask
)
new
PlayTask
().
execute
(
tiempoReproducir
);
botonReproducir
.
setImageResource
(
android
.
R
.
drawable
.
ic_media_pause
);
}
}
});
botonBorrar
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
layoutGrabacion
.
setVisibility
(
View
.
VISIBLE
);
layoutPreview
.
setVisibility
(
View
.
GONE
);
}
});
camara
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
cameraIntent
=
new
Intent
(
android
.
provider
.
MediaStore
.
ACTION_IMAGE_CAPTURE
);
startActivityForResult
(
cameraIntent
,
CAMERA_PIC_REQUEST
);
}
});
galeria
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"image/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
startActivityForResult
(
intent
,
GALLERY_PIC_REQUEST
);
}
});
/**Para bloquear de desplazamiento al pulsar las barras*/
barraReproducir
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
return
true
;
}
}
});
});
}
}
...
@@ -142,4 +410,162 @@ public class EditPictoActivity extends Activity {
...
@@ -142,4 +410,162 @@ public class EditPictoActivity extends Activity {
}
}
}
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
switch
(
requestCode
){
case
REQUEST_RECORD_AUDIO_PERMISSION:
permissionToRecordAccepted
=
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
;
break
;
}
if
(!
permissionToRecordAccepted
)
finish
();
}
private
void
startPlaying
()
{
mPlayer
=
new
MediaPlayer
();
try
{
mPlayer
.
setDataSource
(
mFileName
);
mPlayer
.
prepare
();
mPlayer
.
start
();
}
catch
(
IOException
e
)
{
Log
.
e
(
DEBUG_MESSAGE
,
"prepare() failed"
);
}
}
private
void
stopPlaying
()
{
mPlayer
.
release
();
mPlayer
=
null
;
}
private
void
startRecording
()
{
mRecorder
=
new
MediaRecorder
();
mRecorder
.
setAudioSource
(
MediaRecorder
.
AudioSource
.
MIC
);
mRecorder
.
setOutputFormat
(
MediaRecorder
.
OutputFormat
.
THREE_GPP
);
Log
.
i
(
DEBUG_MESSAGE
,
mFileName
);
mRecorder
.
setOutputFile
(
mFileName
);
mRecorder
.
setAudioEncoder
(
MediaRecorder
.
AudioEncoder
.
AMR_NB
);
try
{
mRecorder
.
prepare
();
}
catch
(
IOException
e
)
{
Log
.
e
(
DEBUG_MESSAGE
,
"prepare() failed"
);
}
mRecorder
.
start
();
}
private
void
stopRecording
()
{
try
{
mRecorder
.
stop
();
mRecorder
.
release
();
}
catch
(
RuntimeException
e
){
Log
.
i
(
DEBUG_MESSAGE
,
"Fallo en stop. No hay grabacion"
);
}
mRecorder
=
null
;
}
private
void
reiniciarGrabacion
(){
tiempoGrabado
=
0
;
textoTGrabacion
.
setText
(
"00:00 | 00:10"
);
}
private
void
reiniciarReproducci
ó
n
(){
tiempoReproducir
=
0
;
barraReproducir
.
setProgress
(
0
);
reproduciendo
=
false
;
botonReproducir
.
setImageResource
(
android
.
R
.
drawable
.
ic_media_play
);
textoTTotal
.
setText
(
"00:00 | 00:"
+(
tiempoTotal
==
10
?
tiempoTotal
:
"0"
+
tiempoTotal
));
}
@Override
public
void
onStop
()
{
super
.
onStop
();
if
(
mRecorder
!=
null
)
{
mRecorder
.
release
();
mRecorder
=
null
;
}
if
(
mPlayer
!=
null
)
{
mPlayer
.
release
();
mPlayer
=
null
;
}
}
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
int
cat
=
getIntent
().
getIntExtra
(
"cat"
,
-
1
);
Bitmap
imagen
=
null
;
Bitmap
rescaled
=
null
;
switch
(
requestCode
)
{
case
CAMERA_PIC_REQUEST:
//Captura de foto
if
(
data
!=
null
&&
resultCode
==
RESULT_OK
)
{
imagen
=
(
Bitmap
)
data
.
getExtras
().
get
(
"data"
);
if
(
imagen
!=
null
)
{
Point
size
=
GUITools
.
getScreenSize
(
EditPictoActivity
.
this
);
float
bWidth
=
imagen
.
getWidth
();
float
bHeight
=
imagen
.
getHeight
();
float
factorX
=
size
.
x
*
0.7f
/
bWidth
;
float
factorY
=
size
.
y
*
0.7f
/
bHeight
;
float
factor
=
factorY
>
factorX
?
factorX
:
factorY
;
bWidth
=
bWidth
*
factor
;
bHeight
=
bHeight
*
factor
;
rescaled
=
Bitmap
.
createScaledBitmap
(
imagen
,(
int
)
bWidth
,
(
int
)
bHeight
,
true
);
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
rescaled
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
byte
[]
byteArray
=
stream
.
toByteArray
();
getIntent
().
putExtra
(
EditPictoActivity
.
IMAGE_PICTO
,
byteArray
);
}
cropImageView
.
setImageBitmap
(
rescaled
);
}
break
;
case
GALLERY_PIC_REQUEST:
//Galeria
if
(
data
!=
null
){
Uri
selectedImage
=
data
.
getData
();
Bitmap
bitmap
=
null
;
try
{
bitmap
=
MediaStore
.
Images
.
Media
.
getBitmap
(
this
.
getContentResolver
(),
selectedImage
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
bitmap
!=
null
)
{
Point
size
=
GUITools
.
getScreenSize
(
EditPictoActivity
.
this
);
float
bWidth
=
bitmap
.
getWidth
();
float
bHeight
=
bitmap
.
getHeight
();
float
factorX
=
size
.
x
*
0.7f
/
bWidth
;
float
factorY
=
size
.
y
*
0.7f
/
bHeight
;
float
factor
=
factorY
>
factorX
?
factorX
:
factorY
;
bWidth
=
bWidth
*
factor
;
bHeight
=
bHeight
*
factor
;
rescaled
=
Bitmap
.
createScaledBitmap
(
bitmap
,(
int
)
bWidth
,
(
int
)
bHeight
,
true
);
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
rescaled
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
stream
);
byte
[]
byteArray
=
stream
.
toByteArray
();
getIntent
().
putExtra
(
EditPictoActivity
.
IMAGE_PICTO
,
byteArray
);
}
cropImageView
.
setImageBitmap
(
rescaled
);
}
break
;
/*case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK) {
int row = getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
String path = data.getExtras().getString(EditPictoActivity.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend);
}
break;*/
}
}
}
}
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/micro.png
0 → 100644
View file @
a3d95466
1.2 KB
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/photo_camera.png
0 → 100644
View file @
a3d95466
864 Bytes
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/photo_gallery.png
0 → 100644
View file @
a3d95466
757 Bytes
android/Pictogram/tabletlibrary/src/main/res/drawable/editpicto_edittext_style.xml
0 → 100644
View file @
a3d95466
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<!-- main color -->
<item
android:bottom=
"2dp"
android:left=
"2dp"
android:right=
"2dp"
>
<shape>
<solid
android:color=
"#FFFFFF"
/>
</shape>
</item>
<item>
<selector
>
<item
android:state_enabled=
"true"
android:state_focused=
"true"
>
<shape>
<stroke
android:width=
"2dp"
android:color=
"@color/VerdeApp"
/>
</shape>
</item>
<item
android:state_enabled=
"true"
>
<shape>
<stroke
android:width=
"2dp"
android:color=
"#ffffffff"
/>
</shape>
</item>
</selector>
</item>
<!-- draw another block to cut-off the left and right bars -->
<item
android:bottom=
"5.0dp"
>
<shape>
<solid
android:color=
"#ffffff"
/>
</shape>
</item>
</layer-list>
android/Pictogram/tabletlibrary/src/main/res/layout/edit_picto_layout.xml
View file @
a3d95466
...
@@ -10,16 +10,17 @@
...
@@ -10,16 +10,17 @@
android:background=
"@android:color/white"
>
android:background=
"@android:color/white"
>
<TextView
<TextView
android:paddingTop=
"@dimen/content_padding_half"
android:id=
"@+id/crop_title"
android:id=
"@+id/crop_title"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/titleCropper"
android:textSize=
"24sp"
android:textColor=
"@color/black"
android:textAlignment=
"center"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:background=
"@color/gray_blue"
/>
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
<LinearLayout
android:orientation=
"horizontal"
android:orientation=
"horizontal"
...
@@ -29,23 +30,53 @@
...
@@ -29,23 +30,53 @@
android:layout_gravity=
"center_horizontal"
>
android:layout_gravity=
"center_horizontal"
>
<LinearLayout
<LinearLayout
android:orientation=
"horizontal"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:id=
"@+id/image_layout"
android:id=
"@+id/image_layout"
android:layout_marginTop=
"@dimen/activity_vertical_margin"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_marginLeft=
"@dimen/activity_vertical_margin"
android:layout_marginLeft=
"@dimen/activity_vertical_margin"
android:gravity=
"center"
>
android:layout_marginTop=
"@dimen/activity_vertical_margin"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.CropImageView
<com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.CropImageView
android:id=
"@+id/CropImageView"
android:id=
"@+id/CropImageView"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:adjustViewBounds=
"true"
android:scaleType=
"centerInside"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:adjustViewBounds=
"true"
android:cropToPadding=
"false"
android:cropToPadding=
"false"
/>
android:orientation=
"horizontal"
android:scaleType=
"centerInside"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/botonera"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginRight=
"25dp"
android:orientation=
"vertical"
>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/camara"
android:layout_width=
"64dp"
android:layout_height=
"64dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:layout_weight=
"0.01"
android:background=
"#00ffffff"
android:src=
"@drawable/photo_camera"
/>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/galeria"
android:layout_width=
"64dp"
android:layout_height=
"64dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:layout_weight=
"0.02"
android:background=
"#00ffffff"
android:src=
"@drawable/photo_gallery"
/>
</LinearLayout>
</LinearLayout>
...
@@ -54,83 +85,207 @@
...
@@ -54,83 +85,207 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/darker_gray"
android:background=
"@android:color/darker_gray"
android:layout_marginRight=
"@dimen/activity_vertical_margin"
/>
android:layout_marginRight=
"@dimen/activity_vertical_margin"
/>
<FrameLayout
<FrameLayout
android:orientation=
"vertical"
android:layout_height=
"match_parent"
android:layout_width=
"wrap_content"
android:id=
"@+id/legend_menu"
android:id=
"@+id/legend_menu"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"right"
android:layout_gravity=
"right"
android:layout_marginRight=
"@dimen/activity_vertical_margin"
android:gravity=
"center"
android:weightSum=
"1"
android:orientation=
"vertical"
android:layout_marginTop=
"@dimen/activity_vertical_margin"
android:paddingRight=
"5dp"
android:gravity=
"center_vertical|center"
>
android:weightSum=
"1"
>
<LinearLayout
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center
_vertical
"
android:layout_gravity=
"center"
android:
layout_marginBottom=
"40dp
"
>
android:
orientation=
"vertical
"
>
<TextView
<TextView
android:textColor=
"@color/gray"
android:id=
"@+id/textLegend"
android:textSize=
"20sp"
android:text=
"@string/legendText"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/textLegend"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
/>
android:text=
"@string/legendText"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<EditText
<EditText
android:textSize=
"20sp"
android:id=
"@+id/edtLegend"
android:imeOptions=
"actionDone"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:id=
"@+id/edtLegend"
android:textColor=
"@color/black"
android:layout_below=
"@+id/textLegend"
android:layout_below=
"@+id/textLegend"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:background=
"@drawable/editpicto_edittext_style"
android:ems=
"10"
android:gravity=
"center"
android:gravity=
"center"
android:
textColorLink=
"?android:attr/colorAccent
"
android:
imeOptions=
"actionDone
"
android:maxLines=
"1"
android:maxLines=
"1"
android:textColor=
"@color/black"
android:textColorLink=
"?android:attr/colorAccent"
android:textCursorDrawable=
"@null"
android:textCursorDrawable=
"@null"
/>
android:textSize=
"20sp"
/>
<TextView
android:id=
"@+id/textView_Audio"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"15dp"
android:text=
"Audio"
android:textColor=
"@color/gray"
android:textSize=
"20sp"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"5dp"
>
<LinearLayout
android:id=
"@+id/layout_record"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingTop=
"5dp"
android:visibility=
"visible"
android:weightSum=
"1"
>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/gifGrabar"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:layout_gravity=
"center"
android:layout_weight=
"0.38"
android:background=
"#00ffffff"
android:src=
"@android:drawable/ic_menu_delete"
/>
<TextView
android:id=
"@+id/tiempoActual"
android:layout_width=
"125dp"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:paddingLeft=
"16dp"
android:paddingRight=
"16dp"
android:text=
"00:00 | 00:10"
android:textColor=
"@color/VerdeApp"
/>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/botonGrabar"
android:layout_width=
"64dp"
android:layout_height=
"64dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:background=
"#00ffffff"
android:clickable=
"true"
android:src=
"@drawable/micro"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/layoutPreview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:background=
"@color/BlancoApp"
android:orientation=
"vertical"
android:paddingBottom=
"5dp"
android:paddingLeft=
"5dp"
android:paddingRight=
"5dp"
android:paddingTop=
"5dp"
android:visibility=
"invisible"
>
<TextView
android:id=
"@+id/textView"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.02"
android:text=
"Preview"
android:textAlignment=
"center"
android:textColor=
"@android:color/black"
/>
<LinearLayout
android:id=
"@+id/LinearLayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/reproducir"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:background=
"#00ffffff"
android:src=
"@android:drawable/ic_media_play"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.00"
android:orientation=
"vertical"
>
<SeekBar
android:id=
"@+id/barraReproducir"
style=
"@style/Widget.AppCompat.SeekBar"
android:layout_width=
"125dp"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/tiempoTotal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"top|center"
android:text=
"00:00 | 00:00"
android:textColor=
"@color/VerdeApp"
/>
</LinearLayout>
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id=
"@+id/botonBorrar"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:layout_alignParentBottom=
"false"
android:layout_centerHorizontal=
"false"
android:background=
"#00ffffff"
android:src=
"@android:drawable/ic_menu_delete"
/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"260dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom|center"
android:layout_marginBottom=
"10dp"
android:gravity=
"bottom|center_horizontal"
android:gravity=
"bottom|center_horizontal"
android:
layout_marginBottom=
"40dp
"
>
android:
orientation=
"horizontal
"
>
<Button
<Button
android:id=
"@+id/okButton"
android:id=
"@+id/okButton"
android:layout_width=
"1
2
0dp"
android:layout_width=
"1
1
0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"?android:attr/textColorPrimary"
android:textSize=
"18sp"
android:textAlignment=
"center"
android:text=
"@string/accept"
android:text=
"@string/accept"
android:
gravity=
"center_horizontal
"
android:
textAlignment=
"center
"
android:
layout_marginLeft=
"10dp
"
android:
textColor=
"?android:attr/textColorPrimary
"
android:
capitalize=
"sentences
"
/>
android:
textSize=
"18sp
"
/>
<Button
<Button
android:id=
"@+id/cancelButton"
android:id=
"@+id/cancelButton"
android:layout_width=
"110dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"?android:attr/textColorPrimary"
android:textSize=
"18sp"
android:textAlignment=
"center"
android:text=
"@string/cancel"
android:text=
"@string/cancel"
android:gravity=
"center_horizontal"
android:textAlignment=
"center"
android:layout_marginRight=
"10dp"
android:textColor=
"?android:attr/textColorPrimary"
android:capitalize=
"sentences"
android:textSize=
"18sp"
/>
android:layout_width=
"120dp"
/>
</LinearLayout>
</LinearLayout>
...
...
android/Pictogram/tabletlibrary/src/main/res/values-en/strings.xml
View file @
a3d95466
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
<string
name=
"session_eval_notevuated"
>
not evaluated
</string>
<string
name=
"session_eval_notevuated"
>
not evaluated
</string>
<string
name=
"session_eval_discarded"
>
discarded
</string>
<string
name=
"session_eval_discarded"
>
discarded
</string>
<string
name=
"crop"
>
Crop
</string>
<string
name=
"crop"
>
Crop
</string>
<string
name=
"titleCropper"
>
Edit Picto
</string>
<string
name=
"cancel"
>
Cancel
</string>
<string
name=
"cancel"
>
Cancel
</string>
<string
name=
"legendText"
>
Legend
</string>
<string
name=
"legendText"
>
Legend
</string>
...
@@ -45,6 +44,8 @@
...
@@ -45,6 +44,8 @@
<!-- Cropper -->
<!-- Cropper -->
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"titleCropperEdit"
>
Edit Picto
</string>
<string
name=
"titleCropperNew"
>
New Picto
</string>
</resources>
</resources>
android/Pictogram/tabletlibrary/src/main/res/values-es/strings.xml
View file @
a3d95466
...
@@ -37,14 +37,14 @@
...
@@ -37,14 +37,14 @@
<string
name=
"session_eval_notevuated"
>
no evaluado
</string>
<string
name=
"session_eval_notevuated"
>
no evaluado
</string>
<string
name=
"session_eval_discarded"
>
inválido
</string>
<string
name=
"session_eval_discarded"
>
inválido
</string>
<string
name=
"crop"
>
Recortar
</string>
<string
name=
"crop"
>
Recortar
</string>
<string
name=
"titleCropper"
>
Nuevo Pictograma
</string>
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<!-- Cropper -->
<!-- Cropper -->
<string
name=
"legendText"
>
Leyenda:
</string>
<string
name=
"legendText"
>
Leyenda:
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"cancel"
>
Cancelar
</string>
<string
name=
"titleCropperEdit"
>
Editar Pictograma
</string>
<string
name=
"titleCropperNew"
>
Nuevo Pictograma
</string>
</resources>
</resources>
android/Pictogram/tabletlibrary/src/main/res/values/strings.xml
View file @
a3d95466
...
@@ -42,8 +42,9 @@
...
@@ -42,8 +42,9 @@
<string
name=
"legendText"
>
Leyenda:
</string>
<string
name=
"legendText"
>
Leyenda:
</string>
<string
name=
"crop"
>
Recortar
</string>
<string
name=
"crop"
>
Recortar
</string>
<string
name=
"titleCropper"
>
Nuevo Pictograma
</string>
<string
name=
"titleCropperNew"
>
Nuevo Pictograma
</string>
<string
name=
"titleCropperEdit"
>
Editar Pictograma
</string>
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<string
name=
"crop_TextRequired"
>
Por favor, introduzca una leyenda para el pictograma
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"cancel"
>
Cancel
</string>
</resources>
</resources>
android/Pictogram/tabletlibrary/tabletlibrary.iml
View file @
a3d95466
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<module
external.linked.project.id=
":tabletlibrary"
external.linked.project.path=
"$MODULE_DIR$"
external.root.project.path=
"$MODULE_DIR$/.."
external.system.id=
"GRADLE"
version=
"4"
>
<module
external.linked.project.id=
":tabletlibrary"
external.linked.project.path=
"$MODULE_DIR$"
external.root.project.path=
"$MODULE_DIR$/.."
external.system.id=
"GRADLE"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<component
name=
"FacetManager"
>
<facet
type=
"android-gradle"
name=
"Android-Gradle"
>
<facet
type=
"android-gradle"
name=
"Android-Gradle"
>
<configuration>
<configuration>
...
...
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