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
96674283
authored
Oct 10, 2017
by
german callejas
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
App icons changed, SessionFragment and PictoAdapter added...
parent
771ee42f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
438 additions
and
2 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/session/PictoAdapter.java
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/session/SessionFragment.java
android/Pictogram/supervisor/src/main/res/drawable/ic_launcher.jpg
android/Pictogram/supervisor/src/main/res/drawable/ic_launcher.png
android/Pictogram/supervisor/src/main/res/drawable/pictogram_logo.jpg
android/Pictogram/supervisor/src/main/res/drawable/pictogram_logo.png
android/Pictogram/tabletlibrary/src/main/res/drawable/ic_launcher.png
android/Pictogram/tabletlibrary/src/main/res/drawable/pictogram_logo.png
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
96674283
...
...
@@ -464,13 +464,13 @@ public class Picto extends Img {
* (i) it has not got category
* (ii) it is not an uncategorized concept (such as "yes","no","thank you")
* @return
*/
public
boolean
is_category
()
{
return
this
.
get_category
()==
Picto
.
NO_CATEGORY
&&
this
.
get_row
()
!=
Picto
.
COL_UNCATEGORIZED_CONCEPTS
&&
this
.
getFreeColumn
()
==
-
1
&&
this
.
getFreeRow
()
==
-
1
;
}
*/
}
/**
*
...
...
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/session/PictoAdapter.java
0 → 100644
View file @
96674283
package
com
.
yottacode
.
pictogram
.
supervisor
.
gui
.
session
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.graphics.PorterDuff
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
com.yottacode.pictogram.tabletlibrary.R
;
import
com.yottacode.tools.BitmapTools
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
java.util.Vector
;
/**
* Created by Fernando on 18/12/2016.
*/
class
PictoAdapter
extends
BaseAdapter
{
private
String
LOG_TAG
=
PictoAdapter
.
class
.
getCanonicalName
();
public
void
setCurrentMsg
(
int
currentMsg
)
{
this
.
currentMsg
=
currentMsg
;
}
public
static
class
Item
{
Bitmap
img
;
String
secs
;
String
sentence
=
""
;
public
Item
(
Bitmap
img
,
String
secs
)
{
this
.
img
=
img
;
this
.
secs
=
secs
;
}
Bitmap
getImg
()
{
return
img
;
}
String
getTime
()
{
return
secs
;
}
public
String
getMsg
()
{
return
sentence
.
toString
();}
public
void
setImg
(
Bitmap
currmsg
,
String
word
,
boolean
eval
)
{
this
.
img
=
currmsg
;
if
(
eval
)
sentence
+=
":"
;
sentence
+=
" "
+
word
;
}
}
Context
context
;
Vector
<
Item
>
msg
;
private
int
currentMsg
=
0
;
final
long
base_time
=
new
Date
().
getTime
();
private
static
LayoutInflater
inflater
=
null
;
public
PictoAdapter
(
Context
context
)
{
this
.
context
=
context
;
msg
=
new
Vector
<>(
3
);
inflater
=
(
LayoutInflater
)
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
}
private
String
getTimeDiff
(
long
time
)
{
long
mills
=
time
-
this
.
base_time
;
int
mins
=
(
int
)
(
mills
/
(
1000
*
60
));
int
secs
=
(
int
)(
mills
/(
1000
))
-
mins
*
60
;
return
"+"
+
mins
+
"' "
+
secs
+
"''"
;
}
@Override
public
int
getCount
()
{
return
msg
.
size
();
}
@Override
public
Item
getItem
(
int
position
)
{
return
msg
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
// TODO Auto-generated method stub
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
vi
=
convertView
;
if
(
vi
==
null
)
vi
=
inflater
.
inflate
(
R
.
layout
.
session_picto_view
,
null
);
ImageView
picto
=(
ImageView
)
vi
.
findViewById
(
R
.
id
.
session_picto
);
picto
.
setImageBitmap
(
this
.
msg
.
get
(
position
).
getImg
());
if
(
currentMsg
==
position
)
{
vi
.
setBackgroundColor
(
Color
.
LTGRAY
);
((
ListView
)
parent
).
smoothScrollToPosition
(
position
);
}
else
vi
.
setBackgroundColor
(
Color
.
TRANSPARENT
);
return
vi
;
}
public
void
addItem
(
Bitmap
bmp
,
String
text
)
{
Item
item
=
this
.
msg
.
get
(
this
.
msg
.
size
()-
1
);
Bitmap
oldmsg
=
item
.
getImg
();
bmp
=
set_text
(
context
,
bmp
,
getTimeDiff
(
new
Date
().
getTime
()));
Bitmap
currmsg
=
combineImages
(
oldmsg
,
bmp
);
item
.
setImg
(
currmsg
,
text
,
false
);
}
public
void
evaluateItem
(
Bitmap
bmp
,
String
evaluation
,
int
position
)
{
Item
item
=
this
.
msg
.
get
(
position
);
Bitmap
oldmsg
=
item
.
getImg
();
float
width
=
context
.
getResources
().
getDimension
(
R
.
dimen
.
picto_session_width
);
float
height
=
context
.
getResources
().
getDimension
(
R
.
dimen
.
picto_session_height
);
bmp
=
new
BitmapTools
(
bmp
).
resize
((
int
)
width
,(
int
)
height
).
get
();
bmp
=
set_text
(
context
,
bmp
,
getTimeDiff
(
new
Date
().
getTime
()));
Bitmap
currmsg
=
position
>=
this
.
msg
.
size
()-
1
?
combineImages
(
oldmsg
,
bmp
)
:
updateImage
(
oldmsg
,
bmp
);
item
.
setImg
(
currmsg
,
evaluation
,
true
);
}
public
int
newMsg
()
{
if
((
msg
.
size
()>
0
&&
msg
.
get
(
msg
.
size
()-
1
).
getImg
().
getWidth
()>
context
.
getResources
().
getDimension
(
R
.
dimen
.
picto_session_width
))
||
msg
.
size
()==
0
)
{
Calendar
calendar
=
GregorianCalendar
.
getInstance
();
// creates a new calendar instance
calendar
.
setTime
(
new
Date
());
// assigns calendar to given date
String
time
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
+
":"
+
calendar
.
get
(
Calendar
.
MINUTE
)
+
":"
+
calendar
.
get
(
Calendar
.
SECOND
);
Bitmap
bmp
=
set_trycount
(
context
,
this
.
msg
.
size
()+
1
);
this
.
currentMsg
=
this
.
msg
.
size
();
msg
.
add
(
new
Item
(
bmp
,
time
));
}
return
msg
.
size
()-
1
;
}
private
Bitmap
combineImages
(
Bitmap
c
,
Bitmap
s
)
{
Bitmap
cs
=
null
;
int
width
,
height
=
0
;
width
=
c
.
getWidth
()
+
s
.
getWidth
();
height
=
c
.
getHeight
();
cs
=
Bitmap
.
createBitmap
(
width
,
height
,
Bitmap
.
Config
.
ARGB_8888
);
Canvas
comboImage
=
new
Canvas
(
cs
);
comboImage
.
drawBitmap
(
c
,
0
f
,
0
f
,
null
);
comboImage
.
drawBitmap
(
s
,
c
.
getWidth
(),
0
f
,
null
);
return
cs
;
}
private
Bitmap
updateImage
(
Bitmap
c
,
Bitmap
s
)
{
Bitmap
cs
=
null
;
int
width
=
c
.
getWidth
(),
height
=
c
.
getHeight
();
int
cutwidth
=
c
.
getWidth
()-
s
.
getWidth
();
cs
=
Bitmap
.
createBitmap
(
width
,
height
,
Bitmap
.
Config
.
ARGB_8888
);
Canvas
comboImage
=
new
Canvas
(
cs
);
comboImage
.
drawBitmap
(
Bitmap
.
createBitmap
(
c
,
0
,
0
,
cutwidth
,
height
),
0
f
,
0
f
,
null
);
comboImage
.
drawBitmap
(
s
,
cutwidth
,
0
f
,
null
);
return
cs
;
}
static
void
set_date
(
Context
context
,
Canvas
canvas
,
String
time
)
{
TextView
textView2
=
new
TextView
(
context
);
textView2
.
layout
(
0
,
20
,
100
,
100
);
textView2
.
setPadding
(
0
,
0
,
0
,
0
);
textView2
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_PX
,
13
);
textView2
.
setTextColor
(
Color
.
BLACK
);
textView2
.
setBackgroundColor
(
Color
.
LTGRAY
);
textView2
.
setWidth
(
100
);
textView2
.
setGravity
(
Gravity
.
CENTER_HORIZONTAL
);
textView2
.
setMaxLines
(
1
);
textView2
.
setText
(
time
);
textView2
.
setDrawingCacheEnabled
(
true
);
canvas
.
drawBitmap
(
textView2
.
getDrawingCache
(),
0
,
60
,
null
);
}
static
Bitmap
set_trycount
(
Context
context
,
int
pos
)
{
Bitmap
param_bitmap
=
BitmapFactory
.
decodeResource
(
context
.
getResources
(),
R
.
drawable
.
try_border
);
float
width
=
context
.
getResources
().
getDimension
(
R
.
dimen
.
picto_session_width
);
float
height
=
context
.
getResources
().
getDimension
(
R
.
dimen
.
picto_session_height
);
Bitmap
bmp
=
Bitmap
.
createScaledBitmap
(
param_bitmap
,
(
int
)
width
,
(
int
)
height
,
false
);
Canvas
canvas
=
new
Canvas
(
bmp
);
TextView
textView
=
new
TextView
(
context
);
String
texto
=(
pos
<
10
?
"0"
:
""
)+
new
Integer
(
pos
).
toString
();
textView
.
layout
(
0
,
0
,
100
,
100
);
textView
.
setPadding
(
0
,
0
,
0
,
0
);
textView
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_PX
,
40
);
textView
.
setTextColor
(
Color
.
BLACK
);
textView
.
setBackgroundColor
(
Color
.
TRANSPARENT
);
textView
.
setWidth
(
100
);
textView
.
setGravity
(
Gravity
.
LEFT
);
textView
.
setMaxLines
(
1
);
textView
.
setText
(
texto
);
textView
.
setDrawingCacheEnabled
(
true
);
canvas
.
drawBitmap
(
textView
.
getDrawingCache
(),
10
,
10
,
null
);
Calendar
calendar
=
GregorianCalendar
.
getInstance
();
// creates a new calendar instance
calendar
.
setTime
(
new
Date
());
// assigns calendar to given date
String
time
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)+
":"
+
calendar
.
get
(
Calendar
.
MINUTE
)+
":"
+
calendar
.
get
(
Calendar
.
SECOND
);
set_date
(
context
,
canvas
,
time
);
return
bmp
;
}
static
Bitmap
set_text
(
Context
context
,
Bitmap
param_bitmap
,
String
texto
)
{
Paint
paint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
float
width
=
param_bitmap
.
getWidth
();
float
height
=
param_bitmap
.
getHeight
();
android
.
graphics
.
Bitmap
.
Config
bitmapConfig
=
param_bitmap
.
getConfig
();
if
(
bitmapConfig
==
null
)
{
bitmapConfig
=
android
.
graphics
.
Bitmap
.
Config
.
ARGB_8888
;
}
Bitmap
bitmap
=
param_bitmap
.
copy
(
bitmapConfig
,
true
);
Canvas
canvas
=
new
Canvas
(
bitmap
);
Bitmap
bm
=
Bitmap
.
createScaledBitmap
(
bitmap
,
(
int
)
Math
.
round
(
0.8
*
width
),
(
int
)
Math
.
round
(
0.8
*
height
),
false
);
canvas
.
drawColor
(
Color
.
TRANSPARENT
,
PorterDuff
.
Mode
.
CLEAR
);
//Poner en blanco el bitmap original para dibujar encima
canvas
.
drawBitmap
(
bm
,
0
,
0
,
paint
);
set_date
(
context
,
canvas
,
texto
);
return
bitmap
;
}
public
int
getCurrentPosition
()
{
return
currentMsg
;
}
public
String
getCurrentMsgText
()
{
return
this
.
getItem
(
currentMsg
).
getMsg
();
}
public
String
getMsgText
(
int
pos
)
{
return
this
.
getItem
(
pos
).
getMsg
();
}
}
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/session/SessionFragment.java
0 → 100644
View file @
96674283
package
com
.
yottacode
.
pictogram
.
supervisor
.
gui
.
session
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.ListView
;
import
com.yottacode.pictogram.dao.Picto
;
import
com.yottacode.pictogram.net.websockets.ActionTalk
;
import
com.yottacode.pictogram.tabletlibrary.R
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.BitmapTools
;
import
org.json.JSONObject
;
import
java.io.IOException
;
public
class
SessionFragment
extends
Fragment
implements
ActionTalk
.
iActionListener
{
interface
iSessionFragment
{
public
void
selectedMsg
(
int
msg_pos
);
public
void
play_msg
();
}
private
iSessionFragment
mListener
=
null
;
ListView
list_pictomsg
;
PictoAdapter
adapter_pictomsg
;
private
boolean
paused
=
false
;
public
SessionFragment
()
{
super
();
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
adapter_pictomsg
=
new
PictoAdapter
(
this
.
getContext
());
setRetainInstance
(
true
);
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_session
,
container
,
false
);
list_pictomsg
=
(
ListView
)
view
.
findViewById
(
R
.
id
.
session_pictomsg_list
);
list_pictomsg
.
setAdapter
(
adapter_pictomsg
);
list_pictomsg
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
((
PictoAdapter
)
list_pictomsg
.
getAdapter
()).
setCurrentMsg
(
position
);
mListener
.
selectedMsg
(
position
);
((
PictoAdapter
)
list_pictomsg
.
getAdapter
()).
notifyDataSetChanged
();
}
});
return
view
;
}
@SuppressWarnings
(
"deprecation"
)
@Override
public
void
onAttach
(
Activity
context
)
{
super
.
onAttach
(
context
);
if
(
mListener
==
null
)
if
(
context
instanceof
iSessionFragment
)
{
mListener
=
(
iSessionFragment
)
context
;
PCBcontext
.
getVocabulary
().
addActionTalkListener
(
this
);
}
else
{
throw
new
RuntimeException
(
context
.
toString
()
+
" must implement OnFragmentInteractionListener"
);
}
}
@Override
public
void
onAttach
(
Context
context
)
{
super
.
onAttach
(
context
);
if
(
mListener
==
null
)
if
(
context
instanceof
iSessionFragment
)
{
mListener
=
(
iSessionFragment
)
context
;
PCBcontext
.
getVocabulary
().
addActionTalkListener
(
this
);
}
else
{
throw
new
RuntimeException
(
context
.
toString
()
+
" must implement OnFragmentInteractionListener"
);
}
}
@Override
public
void
onDetach
()
{
super
.
onDetach
();
PCBcontext
.
getVocabulary
().
removeActionTalkListener
(
this
);
}
@Override
public
void
action
(
action
action
,
int
picto_cat
,
int
picto_id
,
JSONObject
msg
)
{
if
(
action
==
ActionTalk
.
iActionListener
.
action
.
show
)
{
if
(!
paused
)
{
mListener
.
play_msg
();
}
}
else
if
(
action
==
ActionTalk
.
iActionListener
.
action
.
add
||
action
==
ActionTalk
.
iActionListener
.
action
.
select
||
action
==
ActionTalk
.
iActionListener
.
action
.
delete
)
try
{
Picto
picto
=
PCBcontext
.
getVocabulary
().
get_picto
(
picto_cat
,
picto_id
);
Bitmap
bmp
=
picto
.
get_bitmap
(
getContext
());
if
(
action
==
ActionTalk
.
iActionListener
.
action
.
delete
)
{
bmp
=
bmp
.
copy
(
bmp
.
getConfig
(),
true
);
new
BitmapTools
(
bmp
).
paint
((
BitmapDrawable
)
getActivity
().
getResources
().
getDrawable
(
R
.
drawable
.
disabled_picto
,
null
),
1
);
}
else
if
(
PCBcontext
.
getVocabulary
().
get_picto
(
picto_cat
,
picto_id
).
is_category
())
{
bmp
=
bmp
.
copy
(
bmp
.
getConfig
(),
true
);
new
BitmapTools
(
bmp
).
paint
((
BitmapDrawable
)
getActivity
().
getResources
().
getDrawable
(
R
.
drawable
.
session_category
,
null
),
0.5
);
}
if
(
paused
)
{
bmp
=
bmp
.
copy
(
bmp
.
getConfig
(),
true
);
new
BitmapTools
(
bmp
).
paintPause
();
}
this
.
adapter_pictomsg
.
addItem
(
bmp
,
picto
.
get_translation
());
getActivity
().
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
adapter_pictomsg
.
notifyDataSetChanged
();
}});
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
int
newMsg
()
{
int
newmsg_position
=
this
.
adapter_pictomsg
.
newMsg
();
getActivity
().
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
adapter_pictomsg
.
notifyDataSetChanged
();
}});
return
newmsg_position
;
}
public
void
evaluateMsg
(
Bitmap
bmp
,
String
evaluation
,
int
position
)
{
this
.
adapter_pictomsg
.
evaluateItem
(
bmp
,
evaluation
,
position
);
getActivity
().
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
adapter_pictomsg
.
notifyDataSetChanged
();
}});
}
public
void
paused
(
boolean
isChecked
)
{
this
.
paused
=
isChecked
;
}
public
int
get_current_msg_pos
()
{
return
this
.
adapter_pictomsg
.
getCurrentPosition
();
}
public
String
get_current_msg_text
()
{
return
this
.
adapter_pictomsg
.
getCurrentMsgText
();
}
public
int
get_last_msg_pos
()
{
return
adapter_pictomsg
.
getCount
()-
1
;
}
public
String
get_msg_text
(
int
pos
)
{
return
adapter_pictomsg
.
getMsgText
(
pos
);
}
}
android/Pictogram/supervisor/src/main/res/drawable/ic_launcher.jpg
deleted
100644 → 0
View file @
771ee42f
62.4 KB
android/Pictogram/supervisor/src/main/res/drawable/ic_launcher.png
0 → 100644
View file @
96674283
178 KB
android/Pictogram/supervisor/src/main/res/drawable/pictogram_logo.jpg
deleted
100644 → 0
View file @
771ee42f
62.4 KB
android/Pictogram/supervisor/src/main/res/drawable/pictogram_logo.png
0 → 100644
View file @
96674283
178 KB
android/Pictogram/tabletlibrary/src/main/res/drawable/ic_launcher.png
View file @
96674283
46.7 KB
|
W:
|
H:
55.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
android/Pictogram/tabletlibrary/src/main/res/drawable/pictogram_logo.png
View file @
96674283
46.7 KB
|
W:
|
H:
55.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
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