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
b249f8b3
authored
Feb 25, 2016
by
Miguel Ángel García Cumbreras
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Cambios en Serial y LoginActivity
parent
9c32545c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
75 deletions
android/Pictogram/app/src/main/AndroidManifest.xml
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
android/Pictogram/app/src/main/res/layout/activity_login.xml
android/Pictogram/app/src/main/res/layout/fragment_new_student.xml
android/Pictogram/app/src/main/res/layout/list_single.xml
android/Pictogram/app/src/main/res/values-en/strings.xml
android/Pictogram/app/src/main/AndroidManifest.xml
View file @
b249f8b3
...
...
@@ -37,17 +37,11 @@
android:name=
".gui.MainActivity"
android:label=
"@string/app_name"
android:screenOrientation=
"landscape"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
</intent-filter>
</activity>
<activity
android:name=
".gui.SerialActivity"
android:label=
"@string/title_activity_serial"
android:screenOrientation=
"landscape"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
</intent-filter>
</activity>
<activity
android:name=
".gui.LoginActivity"
...
...
@@ -55,17 +49,6 @@
android:label=
"@string/title_activity_login_activity_fragments"
android:screenOrientation=
"landscape"
/>
<activity
android:name=
"com.yottacode.pictogrammar.UploadActivity"
android:label=
"@string/app_name"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".gui.PictogramActivity"
android:exported=
"true"
android:label=
"@string/app_name"
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
View file @
b249f8b3
...
...
@@ -33,6 +33,8 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Vector
;
/**
...
...
@@ -42,7 +44,7 @@ import java.util.Vector;
* @version 1.0
*/
public
class
LoginActivity
extends
FragmentActivity
implements
iRestapiListener
{
public
class
LoginActivity
extends
FragmentActivity
implements
iRestapiListener
{
private
static
final
String
TAG_ID
=
"id"
;
private
static
final
String
TAG_NAME
=
"name"
;
...
...
@@ -154,8 +156,6 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener
public
void
result
(
JSONArray
students_supervisors
)
{
//FERNANDO
try
{
// Saco los pares estudiante-supervisor
//Log.d(LOG_TAG, "JSON:"+students_supervisors);
Log
.
d
(
LOG_TAG
,
"students_supervisors size:"
+
students_supervisors
.
length
());
// looping through All Students
Vector
<
User
>
users
=
new
Vector
<
User
>(
students_supervisors
.
length
());
...
...
@@ -205,64 +205,72 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener
}
}
Log
.
d
(
LOG_TAG
,
"users size:"
+
users
.
size
());
// Si sólo hay 1 estudiante, cargo el st_id
if
(
students_supervisors
.
length
()
==
1
)
if
(
users
.
size
()
==
1
){
//User student = PCBcontext.getDevice().findUser(st_id_int, sup_id);
PCBcontext
.
set_user
(
student
,
token
,
null
);
// no hay que hacer nada cuando termine
}
else
{
student
=
new
User
(-
1
,
""
,
""
,
""
,
"M"
,
"es-es"
,
""
,
sup_id
,
""
,
""
,
""
,
"M"
,
"es-es"
,
""
);
PCBcontext
.
set_user
(
student
,
token
,
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
Log
.
d
(
LOG_TAG
,
"Images: Load images complete"
);
progressDialog
.
dismiss
();
setContentView
(
R
.
layout
.
activity_login
);
//close the progress dialog
//progressDialog.dismiss();
//setContentView(R.layout.activity_login);
}
// De la interfaz iImgDownloaderListener
@Override
public
void
loadImg
(
Img
img
)
{
public
void
loadImg
(
Img
image
)
{
//close the progress dialog
//progressDialog.dismiss();
//setContentView(R.layout.activity_login);
}
});
else
{
student
=
new
User
(-
1
,
""
,
""
,
""
,
"M"
,
"es-es"
,
""
,
sup_id
,
""
,
""
,
""
,
"M"
,
"es-es"
,
""
);
PCBcontext
.
set_user
(
student
,
token
,
null
);
});
}
//Device device = new Device(getApplicationContext(), null, 1);
if
(
users
.
size
()
>
0
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
String
currentDateandTime
=
sdf
.
format
(
new
Date
());
Log
.
d
(
LOG_TAG
,
"Entro en synchronizeUsers en "
+
currentDateandTime
);
PCBcontext
.
getDevice
().
synchronizeUsers
(
users
,
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
}
@Override
public
void
loadComplete
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
String
currentDateandTime
=
sdf
.
format
(
new
Date
());
Log
.
d
(
LOG_TAG
,
"LoadComplete en "
+
currentDateandTime
);
Vector
<
User
>
users
=
null
;
try
{
users
=
PCBcontext
.
getDevice
().
getUsers
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
if
(
users
.
size
()
>
1
)
{
//close the progress dialog
progressDialog
.
dismiss
();
setContentView
(
R
.
layout
.
activity_login
);
}
}
@Override
public
void
loadImg
(
Img
img
)
{
Log
.
d
(
LOG_TAG
,
"Load a single image with ID: "
+
img
.
get_id
());
// Aquí filtro si sólo tiene un único usuario o varios
Vector
<
User
>
users
=
null
;
try
{
users
=
PCBcontext
.
getDevice
().
getUsers
();
if
(
users
.
size
()
>
1
)
{
setContentView
(
R
.
layout
.
activity_login
);
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
@Override
public
void
loadImg
(
Img
image
)
{
}
});
}
});
PCBcontext
.
getDevice
().
deleteDeprecatedImgs
();
// Si sólo hay 1 estudiante paso a Pictogram
if
(
users
.
size
()==
1
)
// Si sólo hay 1 estudiante paso a Pictogram
if
(
users
.
size
()
==
1
){
//close the progress dialog
progressDialog
.
dismiss
();
{
//close the progress dialog
progressDialog
.
dismiss
();
Intent
pictogramActivity
=
new
Intent
(
this
,
PictogramActivity
.
class
);
startActivity
(
pictogramActivity
);
}
}
else
{
Intent
pictogramActivity
=
new
Intent
(
this
,
PictogramActivity
.
class
);
startActivity
(
pictogramActivity
);
}
}
else
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
...
...
@@ -289,9 +297,8 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener
public
void
result
(
JSONObject
result
)
{
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
Toast
.
makeText
(
this
,
"onResume"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
\ No newline at end of file
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
View file @
b249f8b3
...
...
@@ -181,13 +181,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
public
void
onClick
(
View
view
)
{
String
username
=
mSerialViewMail
.
getText
().
toString
();
String
password
=
mSerialViewPass
.
getText
().
toString
();
// DE PRUEBA
// Alumno
//username = "faf0001";
//password = "faf000";
// Supervisor
//username = "dofer@ujaen.es";
//password = "dofer";
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
...
...
@@ -195,6 +188,14 @@ public class SerialActivity extends Activity implements iRestapiListener {
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
// DE PRUEBA
// Alumno
//username = "faf0001";
//password = "faf000";
// Supervisor
username
=
"dofer@ujaen.es"
;
password
=
"dofer"
;
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
// Es un supervisor
...
...
@@ -246,7 +247,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
public
void
result
(
JSONObject
result
)
{
// Si llego aquí es porque hay un único valor, no un array
try
{
//
Log.d(LOG_TAG, "JSON en result:"+result.toString());
Log
.
d
(
LOG_TAG
,
"JSON en result:"
+
result
.
toString
());
if
(
result
.
toString
().
contains
(
"error"
)){
progressDialog
.
dismiss
();
...
...
@@ -345,6 +346,18 @@ public class SerialActivity extends Activity implements iRestapiListener {
progressDialog
.
dismiss
();
}
/*
AlertDialog.Builder builder = new AlertDialog.Builder(SerialActivity.this);
builder.setMessage("Es un supervisor. Sigo...")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog alert = builder.create();
alert.show();
*/
// Llamo a LoginActivity
Intent
loginActivity
=
new
Intent
(
this
,
LoginActivity
.
class
);
loginActivity
.
putExtra
(
"token"
,
jsonToken
);
...
...
android/Pictogram/app/src/main/res/layout/activity_login.xml
View file @
b249f8b3
...
...
@@ -18,7 +18,7 @@
<fragment
android:layout_width=
"fill_parent"
android:layout_height=
"
6
00px"
android:layout_height=
"
4
00px"
class=
"com.yottacode.pictogram.gui.StudentFragmentGrid"
android:id=
"@+id/alumnos"
android:layout_below=
"@+id/logintitle"
/>
...
...
android/Pictogram/app/src/main/res/layout/fragment_new_student.xml
View file @
b249f8b3
...
...
@@ -5,7 +5,7 @@
android:layout_height=
"fill_parent"
android:padding=
"2dp"
android:numColumns=
"5"
android:verticalSpacing=
"
5
dp"
android:verticalSpacing=
"
1
dp"
android:horizontalSpacing=
"5dp"
android:gravity=
"center"
android:layout_alignParentTop=
"true"
...
...
android/Pictogram/app/src/main/res/layout/list_single.xml
View file @
b249f8b3
...
...
@@ -12,5 +12,6 @@
android:id=
"@+id/txt"
android:layout_width=
"140dp"
android:layout_height=
"140dp"
android:layout_centerHorizontal=
"true"
android:layout_below=
"@+id/img"
/>
</RelativeLayout>
\ No newline at end of file
android/Pictogram/app/src/main/res/values-en/strings.xml
View file @
b249f8b3
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Strings de serial -->
<string
name=
"title_activity_serial"
>
Access data
</string>
<string
name=
"action_entrar"
>
Login
</string>
<string
name=
"action_settings"
>
Settings
</string>
<string
name=
"app_name"
>
Pictogram
</string>
<string
name=
"db_script_error"
>
Fail updating the data base
</string>
<string
name=
"error_invalid_serial"
>
These access data are not correct
</string>
<string
name=
"prompt_serial_mail"
>
User
</string>
<string
name=
"prompt_serial_pass"
>
Password
</string>
<string
name=
"title_activity_login"
>
Login
</string>
...
...
@@ -18,7 +19,7 @@
<string
name=
"passErrorTxt"
>
Invalid password
</string>
<string
name=
"passErrorMsg"
>
This password is not correct. Try again.
</string>
<string
name=
"userErrorTxt"
>
User not found
</string>
<string
name=
"userErrorMsg"
>
The user is not correct.
Try again
.
</string>
<string
name=
"userErrorMsg"
>
The user is not correct.
Inténtelo de nuevo
.
</string>
<!-- Alert dialogs -->
<string
name=
"exitPictogram"
>
Exit Pictogram
</string>
...
...
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