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
7910eae4
authored
Apr 18, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merged branch develop into develop
parents
385ff3d0
673d1552
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
95 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/SerialActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/StudentFragmentGrid.java
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/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
7910eae4
...
...
@@ -194,15 +194,19 @@ public class Device extends SQLiteOpenHelper {
return
false
;
}
//TODO: Recuperar los users (supervisors + students) de un alumno
/**
* Recupera los supervisores de un determinado alumno
* @author Germán Callejas
* @param id_stu
* @return
* @throws JSONException
*/
public
Hashtable
<
String
,
String
>
recoverSupervisors
(
Integer
id_stu
)
throws
JSONException
{
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Hashtable
<
String
,
String
>
users
=
new
Hashtable
<>(
3
);
Cursor
cursor
=
db
.
rawQuery
(
" SELECT email_sup, name_sup, surname_sup
FROM users_details
WHERE id_stu = "
+
id_stu
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
" SELECT email_sup, name_sup, surname_sup
,id_sup FROM users_detail
WHERE id_stu = "
+
id_stu
,
null
);
while
(
cursor
.
moveToNext
())
Log
.
i
(
"TAG_PRUEBAS"
,
"Fila: "
+
cursor
.
getInt
(
0
)+
cursor
.
getString
(
1
)+
cursor
.
getString
(
2
)+
cursor
.
getString
(
3
)+
cursor
.
getString
(
4
)+
cursor
.
getString
(
5
)+
cursor
.
getString
(
6
)+
cursor
.
getString
(
7
)+
cursor
.
getString
(
8
)+
cursor
.
getInt
(
9
)+
cursor
.
getString
(
10
)+
cursor
.
getString
(
11
)+
cursor
.
getString
(
12
)+
cursor
.
getString
(
13
)+
cursor
.
getString
(
14
)+
cursor
.
getString
(
15
)+
cursor
.
getString
(
16
)+
cursor
.
getString
(
17
)+
cursor
.
getString
(
18
));
users
.
put
(
cursor
.
getString
(
0
),
cursor
.
getString
(
1
)+
" "
+
cursor
.
getString
(
2
));
users
.
put
(
cursor
.
getString
(
0
),
cursor
.
getString
(
1
)+
", "
+
cursor
.
getString
(
2
)+
";"
+
cursor
.
getInt
(
3
));
cursor
.
close
();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return
users
;
...
...
@@ -285,48 +289,6 @@ public class Device extends SQLiteOpenHelper {
return
users
;
}
/**
* To insert a tuple on users
* @param id_stu
* @param id_sup
*/
public
void
insertUserOnUsers
(
int
id_stu
,
int
id_sup
){
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
beginTransaction
();
db
.
execSQL
(
"INSERT INTO users values ("
+
id_stu
+
", "
+
id_sup
+
")"
);
db
.
setTransactionSuccessful
();
db
.
endTransaction
();
}
/**
* For insert a new supervisor on the local database
*
*/
public
void
insertSupervisor
(
int
id
,
String
email
,
String
pwd
,
String
name
,
String
surname
,
String
url_image
,
String
gender
,
String
lang
,
String
tts_engine
,
String
office
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
beginTransaction
();
db
.
execSQL
(
"INSERT INTO supervisor values ("
+
id
+
", "
+
"'"
+
email
+
"', "
+
(
pwd
==
null
||
pwd
.
length
()==
0
?
"NULL"
:
"'"
+
pwd
+
"'"
)
+
", "
+
"'"
+
name
+
"', "
+
"'"
+
surname
+
"', "
+
"'"
+
url_image
+
"', "
+
"'"
+
gender
+
"', "
+
"'"
+
lang
+
"', "
+
"'"
+
tts_engine
+
"', "
+
"'"
+
office
+
"')"
);
db
.
setTransactionSuccessful
();
db
.
endTransaction
();
Log
.
i
(
"TAG_PRUEBAS"
,
"Supervisor: "
+
email
+
" insertado"
);
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
}
public
void
insertUser
(
User
user
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
beginTransaction
();
...
...
@@ -357,16 +319,18 @@ public class Device extends SQLiteOpenHelper {
}
/**
* Delete all the pairs <id_sup,id_stu> of a student
* Elimina los supervisores asociados a un niño que no tengan password, es decir, los que no hayan estado logueados en el tablet con
* anterioridad
* @author Germán Callejas
* @param stu_id
* @param sup_id
*/
public
void
deleteSupervisor
OfStudentUser
(
int
stu_id
)
{
public
void
deleteSupervisor
(
int
stu_id
,
int
sup_id
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
beginTransaction
();
db
.
execSQL
(
"DELETE FROM users
WHERE id_stu = "
+
stu_id
);
db
.
execSQL
(
"DELETE FROM users
_detail WHERE id_stu = "
+
stu_id
+
" AND id_sup = "
+
sup_id
+
" AND pwd_sup LIKE '_' "
);
db
.
setTransactionSuccessful
();
db
.
endTransaction
();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
}
/**
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
7910eae4
...
...
@@ -165,6 +165,7 @@ public class PictoUploader {
Hashtable
<
String
,
String
>
params
=
new
Hashtable
<
String
,
String
>(
4
);
try
{
JSONObject
json_attrs
=
new
JSONObject
().
put
(
"status"
,
picto
.
get_status
());
json_attrs
.
put
(
"user_avatar"
,
picto
.
get_user_avatar
());
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
json_attrs
.
put
(
Picto
.
JSON_ATTTRS
.
CATEGORY
,
picto
.
get_category
())
.
put
(
Picto
.
JSON_ATTTRS
.
COLUMN
,
picto
.
get_column
())
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/cropper/EditPictoActivity.java
View file @
7910eae4
...
...
@@ -227,8 +227,6 @@ public class EditPictoActivity extends Activity {
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
edit_picto_layout
);
Log
.
i
(
DEBUG_MESSAGE
,
"EDITAR ABIERTO"
);
//Persmisos para grabar audio
ActivityCompat
.
requestPermissions
(
this
,
permissions
,
REQUEST_RECORD_AUDIO_PERMISSION
);
...
...
@@ -237,8 +235,6 @@ public class EditPictoActivity extends Activity {
mDrawerList
=
(
ListView
)
findViewById
(
R
.
id
.
navList
);
/**Obtener la lista de supervisores y aplicarle formato*/
Log
.
i
(
DEBUG_MESSAGE
,
"Usuario: "
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
());
ArrayList
<
String
>
supervisoresAdapter
=
new
ArrayList
<>();
Hashtable
<
String
,
String
>
supervisores
=
null
;
try
{
...
...
@@ -248,21 +244,9 @@ public class EditPictoActivity extends Activity {
}
if
(
supervisores
!=
null
){
for
(
String
email_sup:
supervisores
.
keySet
())
supervisoresAdapter
.
add
(
email_sup
+
", "
+
supervisores
.
get
(
email_sup
)
);
supervisoresAdapter
.
add
(
supervisores
.
get
(
email_sup
).
split
(
";"
)[
0
]+
"\n"
+
email_sup
);
}
supervisoresAdapter
.
add
(
NO_SUP_TEXT
+
"\n"
+
NO_SUP_TEXT
);
//String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
//Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
//ArrayList<String> supervisores = new ArrayList<>();
/*if(supervisors != null) {
String[] separated = supervisors.split(";");
for (String supervisor : separated) {
String[] detalles = supervisor.split(",");
supervisores.add(detalles[0] + "\n" + detalles[1]);
}
}else
Log.i(DEBUG_MESSAGE,"No tiene supervisores...");*/
mAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_list_item_1
,
supervisoresAdapter
);
mDrawerList
.
setAdapter
(
mAdapter
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/SerialActivity.java
View file @
7910eae4
...
...
@@ -16,6 +16,7 @@ import android.widget.Button;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.ListView
;
import
android.widget.Toast
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.dao.UserLogin
;
...
...
@@ -83,13 +84,22 @@ public class SerialActivity extends Activity {
listaSup
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
supUsers
.
elementAt
(
position
).
get_email_sup
());
editor
.
putString
(
"password"
,
supUsers
.
elementAt
(
position
).
get_pwd_sup
());
editor
.
commit
();
new
UserLogin
().
login
(
supUsers
.
elementAt
(
position
).
get_email_sup
(),
supUsers
.
elementAt
(
position
).
get_pwd_sup
(),
SerialActivity
.
this
,
PictogramActivity
.
class
,
LoginActivity
.
class
);
if
(
supUsers
.
elementAt
(
position
).
get_pwd_sup
().
equals
(
"_"
))
{
mSerialViewMail
.
setText
(
supUsers
.
elementAt
(
position
).
get_email_sup
());
mSerialViewPass
.
setText
(
""
);
mSerialViewPass
.
requestFocus
();
Toast
toast
=
Toast
.
makeText
(
PCBcontext
.
getContext
(),
R
.
string
.
insertPasswordLogin
,
Toast
.
LENGTH_SHORT
);
toast
.
show
();
}
else
{
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
supUsers
.
elementAt
(
position
).
get_email_sup
());
editor
.
putString
(
"password"
,
supUsers
.
elementAt
(
position
).
get_pwd_sup
());
editor
.
commit
();
new
UserLogin
().
login
(
supUsers
.
elementAt
(
position
).
get_email_sup
(),
supUsers
.
elementAt
(
position
).
get_pwd_sup
(),
SerialActivity
.
this
,
PictogramActivity
.
class
,
LoginActivity
.
class
);
}
}
});
}
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/StudentFragmentGrid.java
View file @
7910eae4
...
...
@@ -29,6 +29,7 @@ import org.json.JSONObject;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Vector
;
...
...
@@ -203,6 +204,11 @@ public class StudentFragmentGrid extends Fragment{
downloader
.
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
,
imgs
);
}
/**
* Recupera los supervisores de un alumno
* @author Germán Callejas
* @param stu_id
*/
private
void
download_supervisors
(
final
int
stu_id
)
{
String
token
=
getActivity
().
getIntent
().
getExtras
().
getString
(
"token"
);
...
...
@@ -226,42 +232,39 @@ public class StudentFragmentGrid extends Fragment{
@Override
public
void
result
(
JSONArray
supervisors
)
{
//TODO: Obtener supervisores del JSON
//Vector<Integer> idSupervisoresJSON = new Vector<Integer>();
Vector
<
String
>
idSupervisoresJSON
=
new
Vector
<>();
for
(
int
i
=
0
;
i
<
supervisors
.
length
();
i
++)
{
JSONObject
supervisor
=
null
;
try
{
supervisor
=
supervisors
.
getJSONObject
(
i
);
//idSupervisoresJSON.add((Integer) supervisor.get("id"));
//User user = ;
idSupervisoresJSON
.
add
(
supervisor
.
getString
(
"email"
));
if
(!
PCBcontext
.
getDevice
().
isSupervisorOnLocal
((
int
)
supervisor
.
get
(
"id"
)))
{
//Para comprobar si ya existe en local
PCBcontext
.
getDevice
().
insertSupervisor
(
supervisor
.
getInt
(
"id"
),
supervisor
.
getString
(
"email"
),
supervisor
.
getString
(
"name"
),
null
,
supervisor
.
getString
(
"surname"
),
supervisor
.
getString
(
"pic"
),
supervisor
.
getString
(
"gender"
),
supervisor
.
getString
(
"lang"
),
supervisor
.
getString
(
"ttsEngine"
),
supervisor
.
getString
(
"office"
));
/*PCBcontext.getDevice().insertUser(new User(stu_id, PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu()
PCBcontext
.
getDevice
().
insertUser
(
new
User
(
stu_id
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_nickname_stu
(),
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_pwd_stu
()
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
(),
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_surname_stu
(),
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_url_img_stu
()
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_gender_stu
(),
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_lang_stu
(),
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_json_attrs
(),
(int) supervisor.get("id"), supervisor.get("email").toString(), null, supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString()));*/
}
else
{
Log
.
i
(
"TAG_PRUEBAS"
,
"Usuario con id: "
+
supervisor
.
getString
(
"email"
)+
" ya existe"
);
(
int
)
supervisor
.
get
(
"id"
),
supervisor
.
get
(
"email"
).
toString
(),
"_"
,
supervisor
.
get
(
"name"
).
toString
(),
supervisor
.
get
(
"surname"
).
toString
(),
supervisor
.
get
(
"pic"
).
toString
(),
supervisor
.
get
(
"gender"
).
toString
(),
supervisor
.
get
(
"lang"
).
toString
(),
supervisor
.
get
(
"ttsEngine"
).
toString
(),
supervisor
.
get
(
"office"
).
toString
()));
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
/*try {
Vector<User> supervisorsLocal = PCBcontext.getDevice().recoverSupervisors(stu_id);
for(User user: supervisorsLocal){
if(!idSupervisoresJSON.contains(user.get_id_sup())){
PCBcontext.getDevice().deleteUser(stu_id);
/**Eliminar los que habia y que ya no vienen en el JSON */
try
{
Hashtable
<
String
,
String
>
supervisorsLocal
=
PCBcontext
.
getDevice
().
recoverSupervisors
(
stu_id
);
if
(
supervisorsLocal
!=
null
&&
!
supervisorsLocal
.
isEmpty
()){
for
(
String
email_sup:
supervisorsLocal
.
keySet
()){
if
(!
idSupervisoresJSON
.
contains
(
email_sup
)){
//Coge la segunda parte ya que el formato del dato es Nombre, Apellidos;id_sup
PCBcontext
.
getDevice
().
deleteSupervisor
(
stu_id
,
Integer
.
parseInt
(
supervisorsLocal
.
get
(
email_sup
).
split
(
";"
)[
1
]));
}
}
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}*/
//PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat);
}
}
@Override
...
...
android/Pictogram/tabletlibrary/src/main/res/values-en/strings.xml
View file @
7910eae4
...
...
@@ -46,6 +46,7 @@
<string
name=
"uploadingImage"
>
Subiendo imagen al servidor
</string>
<string
name=
"titleCropperEdit"
>
Edit Picto
</string>
<string
name=
"titleCropperNew"
>
New Picto
</string>
<string
name=
"insertPasswordLogin"
>
Insert Password
</string>
</resources>
android/Pictogram/tabletlibrary/src/main/res/values-es/strings.xml
View file @
7910eae4
<resources>
<string
name=
"app_name"
>
com.yottacode.pictogram.Tablet
</string>
<string
name=
"alumnos"
>
Estrudiante
s
</string>
<string
name=
"alumnos"
>
Alumno
s
</string>
<string
name=
"supervisores"
>
Supervisores
</string>
<item
name=
"maxInTape"
type=
"integer"
>
8
</item>
<item
name=
"maxInTape_big"
type=
"integer"
>
6
</item>
...
...
@@ -45,6 +45,7 @@
<string
name=
"cancel"
>
Cancelar
</string>
<string
name=
"titleCropperEdit"
>
Editar Pictograma
</string>
<string
name=
"titleCropperNew"
>
Nuevo Pictograma
</string>
<string
name=
"insertPasswordLogin"
>
Inserte Contraseña
</string>
</resources>
android/Pictogram/tabletlibrary/src/main/res/values/strings.xml
View file @
7910eae4
...
...
@@ -49,4 +49,5 @@
<string
name=
"cancel"
>
Cancel
</string>
<string
name=
"drawer_open"
>
Open Menu
</string>
<string
name=
"drawer_close"
>
Close Menu
</string>
<string
name=
"insertPasswordLogin"
>
Inserte Contraseña
</string>
</resources>
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