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
5486da0b
authored
Sep 08, 2016
by
root
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'develop' of
http://scm.ujaen.es/softuno/pictogram
into develop
parents
87074dd7
c03f331d
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
106 additions
and
88 deletions
README.md
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/Action.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictoAction.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictosAction.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/Room.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/SubscribeAction.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/UnsubscribeAction.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/Img.java
android/Pictogram/tablet/src/main/java/com/yottacode/pictogram/tablet/gui/LoginActivity.java
android/Pictogram/tablet/src/main/java/com/yottacode/pictogram/tablet/gui/StudentFragmentGrid.java
android/Pictogram/tablet/src/main/res/layout/activity_main.xml
android/Pictogram/tablet/src/main/res/layout/activity_serial.xml
sails/install.sh
README.md
View file @
5486da0b
...
...
@@ -16,7 +16,7 @@ Para comprobar que todo funciona correctamente se ha habilitado un servidor con
comprueba que el código está bien escrito y funciona correctamente (actualmente sólo para el
código JavaScript). Datos del servidor:
-
Dirección:
[
ararat.ujaen.es
][
5
]
-
Dirección:
[
ci.yottacode.com
][
5
]
-
Usuario:
`uruk`
-
Contraseña:
`saruman es et`
...
...
@@ -27,4 +27,4 @@ código JavaScript). Datos del servidor:
[
2
]:
/softuno/pictogram/tree/develop/sails
[
3
]:
/softuno/pictogram/tree/develop/sails/src/assets/app
[
4
]:
/softuno/pictogram/tree/develop/android/Pictogram
[
5
]:
https://ararat.ujaen.es/jenkins
\ No newline at end of file
[
5
]:
https://ci.yottacode.com
\ No newline at end of file
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/Action.java
View file @
5486da0b
...
...
@@ -35,6 +35,8 @@ public abstract class Action {
this
.
type
=
type
;
}
abstract
public
boolean
is_local_action
();
public
String
get_type
()
{
return
this
.
type
;}
public
abstract
String
get_action
();
protected
JSONObject
get_json
()
{
...
...
@@ -79,4 +81,4 @@ public abstract class Action {
return
null
;
}
}
\ No newline at end of file
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictoAction.java
View file @
5486da0b
...
...
@@ -49,6 +49,8 @@ public abstract class PictoAction extends Action {
return
null
;
}
}
public
boolean
is_local_action
()
{
return
this
.
picto
.
is_local
();}
public
JSONObject
get_json_picto
()
throws
JSONException
{
final
String
param_id_json
=
"id"
;
final
String
param_picto
=
"picto"
;
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/PictosAction.java
View file @
5486da0b
...
...
@@ -59,6 +59,9 @@ public class PictosAction extends Action {
return
null
;
}
}
public
boolean
is_local_action
()
{
return
false
;}
private
JSONObject
get_json_picto
(
Picto
picto
)
throws
JSONException
{
final
String
param_id_json
=
"id"
;
final
String
param_picto
=
"picto"
;
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/Room.java
View file @
5486da0b
...
...
@@ -54,20 +54,23 @@ public class Room {
}
public
void
emit
(
final
Action
action
)
{
String
token
=
PCBcontext
.
getRestapiWrapper
().
getToken
();
final
String
token_param
=
"token"
;
Log
.
i
(
this
.
getClass
().
getName
(),
"Action: "
+
action
.
get_type
()
+
" / Attributes emitted: "
+
action
.
get_json
().
toString
());
try
{
if
(!
action
.
is_local_action
())
{
String
token
=
PCBcontext
.
getRestapiWrapper
().
getToken
();
final
String
token_param
=
"token"
;
Log
.
i
(
this
.
getClass
().
getName
(),
"Action: "
+
action
.
get_type
()
+
" / Attributes emitted: "
+
action
.
get_json
().
toString
());
try
{
this
.
socket
.
emit
(
action
.
get_action
(),
this
.
common_data
(
action
.
get_type
(),
action
.
get_json
()).
put
(
token_param
,
token
),
new
Ack
()
{
@Override
public
void
call
(
Object
...
args
)
{
for
(
Object
arg
:
args
)
Log
.
d
(
this
.
getClass
().
getName
(),
"Ack messsage:"
+
arg
);
}
@Override
public
void
call
(
Object
...
args
)
{
for
(
Object
arg
:
args
)
Log
.
d
(
this
.
getClass
().
getName
(),
"Ack messsage:"
+
arg
);
}
});
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getClass
().
getCanonicalName
()
+
e
.
getMessage
()
+
"--"
+
e
.
getLocalizedMessage
());
}
}
else
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Local Action "
+
action
.
get_action
()+
" is not emitted"
);
}
/**
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/SubscribeAction.java
View file @
5486da0b
...
...
@@ -20,12 +20,15 @@ public class SubscribeAction extends Action {
public
static
final
String
ACTION
=
"/stu/subscribe"
;
@Override
public
boolean
is_local_action
()
{
return
false
;
}
public
SubscribeAction
(
){
public
SubscribeAction
(
){
super
(
SUBSCRIBE
);
}
public
String
get_action
()
{
return
ACTION
;}
}
\ No newline at end of file
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/action/UnsubscribeAction.java
View file @
5486da0b
...
...
@@ -24,6 +24,10 @@ public class UnsubscribeAction extends Action {
super
(
UNSUBSCRIBE
);
}
@Override
public
boolean
is_local_action
()
{
return
false
;
}
public
String
get_action
()
{
return
ACTION
;}
public
String
get_action
()
{
return
ACTION
;}
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
5486da0b
...
...
@@ -82,15 +82,7 @@ public class Picto extends Img {
* @return true if it's a local pictogram
*/
public
boolean
is_local
()
{
return
this
.
get_id
()<
0
;}
/**
*
* @return de id of the picto
*/
public
int
get_id
()
{
return
this
.
id
;}
public
void
update_id
(
int
id
)
{
this
.
id
=
id
;
}
/**
*
* @return the location of the picto
...
...
@@ -344,7 +336,9 @@ public class Picto extends Img {
* @return true if current status is enabled. False in other case.
*/
public
boolean
alter_status
()
{
String
status
=
is_enabled
()
?
JSON_ATTTR_STATUS_VALUES
.
DISABLED
:
JSON_ATTTR_STATUS_VALUES
.
ENABLED
;
String
status
=
is_enabled
()
?
JSON_ATTTR_STATUS_VALUES
.
DISABLED
:
is_disabled
()
?
JSON_ATTTR_STATUS_VALUES
.
INVISIBLE
:
JSON_ATTTR_STATUS_VALUES
.
ENABLED
;
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
STATUS
,
status
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
5486da0b
...
...
@@ -142,12 +142,6 @@ public class NetService implements Runnable {
}
public
void
notifyStatus
()
{
String
user
;
if
(
PCBcontext
.
getPcbdb
()!=
null
)
{
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
();
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_supervisor
())
user
+=
" ("
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_sup
()
+
")"
;
}
device
.
notifyStatus
(
this
.
updated
);
}
public
void
closeNotifyStatus
(){
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
5486da0b
...
...
@@ -40,8 +40,8 @@ public class PictoUploader {
this
.
picto
=
picto
;
}
private
int
uploadImg
(
Img
img
)
throws
UnsupportedEncodingException
{
int
img_id
;
private
boolean
uploadImg
(
Img
img
)
throws
UnsupportedEncodingException
{
boolean
success
;
Bitmap
bmp
=
null
;
Response
<
JsonObject
>
response
=
null
;
if
(!
img
.
get_filetype
().
equalsIgnoreCase
(
"png"
))
...
...
@@ -72,9 +72,13 @@ public class PictoUploader {
if
(
response
!=
null
&&
response
.
getHeaders
().
code
()
==
200
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploaded image result: "
+
response
.
getHeaders
()
+
":"
+
response
.
getResult
());
img_id
=
response
.
getResult
().
get
(
"id"
).
getAsInt
();
int
img_id
=
response
.
getResult
().
get
(
"id"
).
getAsInt
();
String
img_uri
=
response
.
getResult
().
get
(
"uri"
).
getAsString
();
img
.
set_url
(
img_uri
);
img
.
update_id
(
img_id
);
success
=
true
;
}
else
{
img_id
=-
1
;
success
=
false
;
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploaded image failed "
);
if
(
response
!=
null
)
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Uploaded image failed, headers: "
+
response
.
getHeaders
());
...
...
@@ -82,19 +86,19 @@ public class PictoUploader {
}
catch
(
InterruptedException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Image upload error: "
+
e
.
getMessage
()+
"Code: "
+
(
response
==
null
?
-
1
:
response
.
getHeaders
().
code
()));
img_id
=-
1
;
success
=
false
;
}
catch
(
ExecutionException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Image upload error: "
+
e
.
getMessage
()+
(
response
==
null
?
-
1
:
response
.
getHeaders
().
code
()));
img_id
=-
1
;
success
=
false
;
}
catch
(
IOException
e
)
{
Log
.
e
(
Img
.
class
.
getCanonicalName
(),
"Error when decoding "
+
img
.
file_name
());
GUITools
.
show_alert
(
PCBcontext
.
getContext
(),
R
.
string
.
imguserLoadingErrMsg
);
img_id
=-
1
;
success
=
false
;
}
// ion.dump();
return
img_id
;
return
success
;
}
...
...
@@ -186,7 +190,7 @@ public class PictoUploader {
**/
public
void
upload
(
final
Context
context
)
throws
IOException
{
final
int
local_img_id
=
this
.
picto
.
get_id
();
final
int
img_id
=
uploadImg
(
this
.
picto
);
final
boolean
imgUpload_success
=
uploadImg
(
this
.
picto
);
iPictoUploaderListener
listener
=
new
iPictoUploaderListener
()
{
int
elements_uploaded
=
0
;
...
...
@@ -199,15 +203,14 @@ public class PictoUploader {
if
(
elements_uploaded
==
2
)
{
PCBcontext
.
getPcbdb
().
deletePicto
(
local_img_id
);
PictoUploader
.
this
.
picto
.
delete_bitmap
(
PCBcontext
.
getContext
());
PictoUploader
.
this
.
picto
.
update_id
(
img_id
);
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ADD
,
PictoUploader
.
this
.
picto
));
GUITools
.
show_alert
(
context
,
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
()
+
":"
+
PictoUploader
.
this
.
picto
.
get_id
()
);
GUITools
.
show_alert
(
context
,
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
}
};
if
(
img
_id
>
0
)
{
uploadAttributes
(
img_id
,
listener
);
uploadTranslation
(
img_id
,
listener
);
if
(
img
Upload_success
)
{
uploadAttributes
(
picto
.
get_id
()
,
listener
);
uploadTranslation
(
picto
.
get_id
()
,
listener
);
}
else
{
GUITools
.
show_alert
(
context
,
R
.
string
.
upload_error
,
PictoUploader
.
this
.
picto
.
get_translation
());
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/Img.java
View file @
5486da0b
...
...
@@ -66,6 +66,10 @@ public class Img {
public
String
get_type
()
{
return
this
.
type
;}
public
String
get_filetype
()
{
return
Img
.
FILETYPE
;}
public
void
update_id
(
int
id
)
{
this
.
id
=
id
;
}
/**
* Load if necessary the bitmap from disk, and it is returned. IIf it is not available, return null
* @param context
...
...
android/Pictogram/tablet/src/main/java/com/yottacode/pictogram/tablet/gui/LoginActivity.java
View file @
5486da0b
...
...
@@ -39,23 +39,27 @@ public class LoginActivity extends FragmentActivity {
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
activity_login
);
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
activity_login
);
// Enable logout button
// Enable logout button
final
Button
logoutButton
=
(
Button
)
findViewById
(
R
.
id
.
loginTopbarLogout
);
logoutButton
.
setEnabled
(
true
);
logoutButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
serialActivity
=
new
Intent
(
getBaseContext
(),
SerialActivity
.
class
);
serialActivity
.
putExtra
(
"resetPrevUser"
,
true
);
startActivity
(
serialActivity
);
}
});
final
Button
logoutButton
=
(
Button
)
findViewById
(
R
.
id
.
loginTopbarLogout
);
logoutButton
.
setEnabled
(
true
);
logoutButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
serialActivity
=
new
Intent
(
getBaseContext
(),
SerialActivity
.
class
);
serialActivity
.
putExtra
(
"resetPrevUser"
,
true
);
startActivity
(
serialActivity
);
}
});
}
@Override
protected
void
onStart
()
{
super
.
onStart
();
// Set supervisor information on topbar
final
TextView
supervisorFullNameView
=
(
TextView
)
findViewById
(
R
.
id
.
loginTopbarSupervisorFullName
);
...
...
android/Pictogram/tablet/src/main/java/com/yottacode/pictogram/tablet/gui/StudentFragmentGrid.java
View file @
5486da0b
...
...
@@ -115,12 +115,9 @@ public class StudentFragmentGrid extends Fragment{
PCBcontext
.
set_user
(
new_user
,
intent
.
getStringExtra
(
"token"
),
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
if
(
progressDialog
.
isShowing
())
{
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
Intent
pictogramActivity
=
new
Intent
(
getActivity
(),
PictogramActivity
.
class
);
startActivity
(
pictogramActivity
);
}
}
@Override
...
...
@@ -128,7 +125,7 @@ public class StudentFragmentGrid extends Fragment{
}
public
void
error
(
Exception
e
)
{
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
GUITools
.
show_alert
(
StudentFragmentGrid
.
this
.
getActivity
(),
R
.
string
.
serverError
,
e
.
getMessage
());
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Server error:"
+
e
.
getLocalizedMessage
());
}
...
...
@@ -168,7 +165,7 @@ public class StudentFragmentGrid extends Fragment{
ImgDownloader
downloader
=
new
ImgDownloader
(
getActivity
(),
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
if
(
downloaded_students
.
size
()
>
1
)
{
for
(
int
i
=
0
;
i
<
imgs
.
size
();
i
++)
try
{
...
...
@@ -188,7 +185,7 @@ public class StudentFragmentGrid extends Fragment{
public
void
loadImg
(
Img
image
)
{
}
public
void
error
(
Exception
e
)
{
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
GUITools
.
show_alert
(
PCBcontext
.
getContext
(),
R
.
string
.
serverError
,
e
.
getMessage
());
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Server error:"
+
e
.
getLocalizedMessage
());
}
...
...
@@ -209,7 +206,7 @@ public class StudentFragmentGrid extends Fragment{
@Override
public
void
error
(
Exception
e
)
{
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
GUITools
.
show_alert
(
getActivity
(),
R
.
string
.
loginErrorTxt
,
getString
(
R
.
string
.
serverError
),
new
GUITools
.
iOKListener
()
{
@Override
public
void
ok
()
{
...
...
@@ -222,7 +219,7 @@ public class StudentFragmentGrid extends Fragment{
}
@Override
public
void
result
(
JSONArray
students
)
{
progressDialog
.
dismiss
();
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
StudentFragmentGrid
.
this
.
downloaded_students
=
new
Vector
();
for
(
int
i
=
0
;
i
<
students
.
length
();
i
++)
{
JSONObject
student
;
...
...
@@ -261,8 +258,13 @@ public class StudentFragmentGrid extends Fragment{
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setRetainInstance
(
true
);
super
.
onCreate
(
savedInstanceState
);
setRetainInstance
(
true
);
}
@Override
public
void
onStart
()
{
super
.
onStart
();
Intent
intent
=
getActivity
().
getIntent
();
Boolean
offline
=
intent
.
getBooleanExtra
(
"offline"
,
false
);
int
sup_id
=
intent
.
getIntExtra
(
"sup_id"
,
0
);
...
...
@@ -293,15 +295,17 @@ public class StudentFragmentGrid extends Fragment{
}
else
download_students
(
sup_id
);
}
if
(
offline
||
onlineStudentsOK
)
showStudentsGrid
();
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_new_student
,
container
,
false
);
gridView
=
(
GridView
)
view
.
findViewById
(
R
.
id
.
loginStudentGridView
);
Boolean
offline
=
getActivity
().
getIntent
().
getBooleanExtra
(
"offline"
,
false
);
if
(
offline
||
onlineStudentsOK
)
showStudentsGrid
();
return
view
;
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_new_student
,
container
,
false
);
gridView
=
(
GridView
)
view
.
findViewById
(
R
.
id
.
loginStudentGridView
);
return
view
;
}
}
android/Pictogram/tablet/src/main/res/layout/activity_main.xml
View file @
5486da0b
...
...
@@ -25,7 +25,8 @@
<EditText
android:id=
"@+id/edittext"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
android:password=
"true"
/>
<!-- The "Translate!" button -->
<Button
android:id=
"@+id/button"
...
...
@@ -54,4 +55,4 @@
android:layout_height=
"fill_parent"
android:layout_weight=
"1"
/>
</LinearLayout>
\ No newline at end of file
</LinearLayout>
android/Pictogram/tablet/src/main/res/layout/activity_serial.xml
View file @
5486da0b
...
...
@@ -8,7 +8,7 @@
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
".SerialActivity"
>
tools:context=
".
gui.
SerialActivity"
>
<EditText
android:id=
"@+id/serialmail"
...
...
@@ -30,10 +30,11 @@
android:imeActionId=
"@+id/login"
android:imeActionLabel=
"@string/action_entrar"
android:imeOptions=
"actionUnspecified"
android:inputType=
"text"
android:inputType=
"text
Password
"
android:maxLines=
"1"
android:singleLine=
"true"
android:layout_below=
"@+id/serialmail"
/>
android:layout_below=
"@+id/serialmail"
/>
<Button
android:id=
"@+id/entrar_button"
style=
"?android:textAppearanceSmall"
...
...
sails/install.sh
View file @
5486da0b
...
...
@@ -30,4 +30,4 @@ elif [ -e "/home/vagrant/sync/playbook.yml" ]; then
else
echo
"XX Playbook not found, provision not finished"
exit
fi
\ No newline at end of file
fi
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