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
c24e7a2f
authored
Jan 04, 2018
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Pictogram 1.6, Beta 4, issue
#431
,
#421
, chivato de conexion en tablet supervisor incluido
parent
0e023f96
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
102 additions
and
31 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/TransactionMonitor.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/UserLogin.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/ServerLogin.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/StudentTalk.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/communicator/build/intermediates/incremental/mergeDevFlavorDebugResources/compile-file-map.properties
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/VocabularyManager.java
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/login/LoginActivity.java
android/Pictogram/supervisor/src/main/res/layout/activity_login.xml
android/Pictogram/supervisor/src/main/res/layout/vocabulary_manager.xml
android/Pictogram/supervisor/src/main/res/layout/vocabulary_manager_big.xml
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/SerialActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/net/NetServiceTablet.java
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/application_online.png
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/TransactionMonitor.java
View file @
c24e7a2f
...
...
@@ -15,14 +15,17 @@ public class TransactionMonitor {
return
db
;
}
static
public
void
startTransaction
(
SQLiteOpenHelper
helper
)
{
db
=
helper
.
getWritableDatabase
();
db
.
enableWriteAheadLogging
();
db
.
beginTransactionNonExclusive
();
Log
.
i
(
LOG_TAG
,
"Transaction begins"
);
if
(
getDBOnTransaction
()==
null
)
{
db
=
helper
.
getWritableDatabase
();
db
.
enableWriteAheadLogging
();
db
.
beginTransactionNonExclusive
();
Log
.
i
(
LOG_TAG
,
"Transaction begins "
);
}
else
Log
.
e
(
LOG_TAG
,
"*********************Transaction is previously started and not finished"
);
}
static
public
void
endTransaction
(
boolean
succesfull
)
{
if
(
succesfull
&&
db
.
inTransaction
())
{
//puede ocurrir que no haya nada
db
.
setTransactionSuccessful
();
if
(
db
.
inTransaction
())
{
//puede ocurrir que no haya nada
if
(
succesfull
)
db
.
setTransactionSuccessful
();
Log
.
i
(
LOG_TAG
,
"Transaction ends. Successfully? "
+
succesfull
);
db
.
endTransaction
();
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
c24e7a2f
...
...
@@ -63,12 +63,20 @@ public class Device extends SQLiteOpenHelper {
}
}
@Override
public
SQLiteDatabase
getWritableDatabase
()
{
SQLiteDatabase
db
=
TransactionMonitor
.
getDBOnTransaction
();
if
(
db
==
null
)
db
=
super
.
getWritableDatabase
();
return
db
;
}
/**
* Set the value of a param.
*
*/
private
void
setParam
(
String
param
,
String
value
)
{
setParam
(
this
.
getWritableDatabase
(),
param
,
value
);
setParam
(
this
.
getWritableDatabase
(),
param
,
value
);
}
/**
...
...
@@ -315,9 +323,7 @@ public class Device extends SQLiteOpenHelper {
public
void
insertUser
(
User
user
)
{
SQLiteDatabase
db
=
TransactionMonitor
.
getDBOnTransaction
();
if
(
db
==
null
)
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
String
sentence
=
"INSERT INTO users_detail values ("
+
user
.
get_id_stu
()
+
", "
+
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
c24e7a2f
...
...
@@ -263,7 +263,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values
.
put
(
"url"
,
picto
.
get_url
());
values
.
put
(
"translation"
,
picto
.
get_translation
());
values
.
put
(
"attributes"
,
picto
.
get_json_attrs
());
db
.
insert
(
"collection_detail"
,
null
,
values
);
db
.
insert
WithOnConflict
(
"collection_detail"
,
null
,
values
,
SQLiteDatabase
.
CONFLICT_REPLACE
);
}
Log
.
i
(
LOG_TAG
,
"Storage "
+
n
+
" pictos for student "
+
id_stu
);
//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/dao/UserLogin.java
View file @
c24e7a2f
...
...
@@ -266,6 +266,7 @@ public class UserLogin {
}
public
void
login
(
String
username
,
String
password
,
Activity
activity
,
Class
activityAfterLogin
)
{
if
(
PCBcontext
.
is_user_logged
())
PCBcontext
.
unset_user
();
boolean
online
=
RestapiWrapper
.
ping
(
activity
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
);
if
(
isSupervisorLoginPattern
(
username
))
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
c24e7a2f
...
...
@@ -270,6 +270,7 @@ public class Vocabulary implements Iterable<Picto> {
else
{
startpictos
=
new
LinkedList
<>();
LinkedList
<
Picto
>
pictos
=
this
.
pictos
.
get
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
());
if
(
pictos
!=
null
&&
pictos
.
size
()>
0
)
for
(
Picto
picto
:
pictos
)
{
startpictos
.
add
(
picto
);
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
c24e7a2f
...
...
@@ -134,7 +134,10 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
public
void
restart_app
(
boolean
resetPrevLogin
)
{
for
(
iNetServiceStatus
listener:
listeners
)
if
(
listener
instanceof
iNetServiceDevice
)
((
iNetServiceDevice
)
listener
).
restart_app
(
resetPrevLogin
);
if
(
listener
instanceof
iNetServiceDevice
)
{
((
iNetServiceDevice
)
listener
).
restart_app
(
resetPrevLogin
);
break
;
}
}
...
...
@@ -253,7 +256,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
try
{
objects
=
new
Object
[]{
new
JSONObject
().
put
(
"student"
,
result
)};
PCBcontext
.
getStudentTalk
().
call
(
objects
);
Log
.
i
(
LOG_TAG
,
"Student attributes synchroniz
ed
"
);
Log
.
i
(
LOG_TAG
,
"Student attributes synchroniz
ing
"
);
PCBcontext
.
getVocabulary
().
synchronize
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
...
...
@@ -300,6 +303,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
}
}
/**
* Created by Fernando on 12/08/2016.
*/
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/ServerLogin.java
View file @
c24e7a2f
...
...
@@ -17,6 +17,8 @@ import java.util.Hashtable;
*/
public
class
ServerLogin
{
private
static
final
String
LOG_TAG
=
ServerLogin
.
class
.
getSimpleName
();
public
static
void
login_student
(
String
username
,
String
password
,
RestapiWrapper
.
iRestapiListener
listener
)
{
login
(
"stu/login"
,
null
,
username
,
password
,
listener
);
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/StudentTalk.java
View file @
c24e7a2f
...
...
@@ -18,7 +18,7 @@ public class StudentTalk implements Emitter.Listener {
private
static
final
String
URL
=
"updateStudent"
;
private
static
final
String
LOG_TAG
=
StudentTalk
.
class
.
getCanonicalName
();
private
String
lastTalk
=
null
;
private
final
iStudentListener
[]
listeners
;
...
...
@@ -32,7 +32,12 @@ public class StudentTalk implements Emitter.Listener {
if
(
PCBcontext
.
getPcbdb
()!=
null
)
try
{
JSONObject
msg
=((
JSONObject
)
args
[
0
]).
getJSONObject
(
"student"
);
Log
.
d
(
this
.
getClass
().
getName
(),
"Raw message: "
+
msg
.
toString
());
if
(
lastTalk
!=
null
&&
lastTalk
.
equals
(
msg
.
toString
()))
{
Log
.
e
(
LOG_TAG
,
"********************************Message from server duplicated!"
);
return
;
}
lastTalk
=
msg
.
toString
();
int
id
=
msg
.
getInt
(
"id"
);
String
username
=
msg
.
getString
(
"username"
);
String
name
=
msg
.
getString
(
"name"
);
...
...
@@ -46,7 +51,7 @@ public class StudentTalk implements Emitter.Listener {
JSONObject
license
=
msg
.
getJSONObject
(
"license"
);
Log
.
i
(
LOG_TAG
,
"raw Received message "
+
msg
.
toString
());
User
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
();
User
updatedUser
=
new
User
(
id
,
username
,
user
.
get_pwd_stu
(),
name
,
surname
,
id_active_scene
,
pic
,
gender
,
lang
,
attributes
,
user
.
get_id_sup
(),
user
.
get_email_sup
(),
user
.
get_pwd_sup
(),
user
.
get_name_sup
(),
user
.
get_surname_sup
(),
user
.
get_url_img_sup
(),
user
.
get_gender_sup
(),
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
c24e7a2f
...
...
@@ -7,6 +7,7 @@ import android.util.Log;
import
com.yottacode.net.RestapiWrapper
;
import
com.yottacode.net.SSLDummyContext
;
import
com.yottacode.net.TransactionMonitor
;
import
com.yottacode.pictogram.commonlibrary.R
;
import
com.yottacode.pictogram.action.ActionLog
;
import
com.yottacode.pictogram.dao.Device
;
...
...
@@ -109,7 +110,7 @@ public final class PCBcontext {
if
(
updatedStudent
.
is_picto_size_big
()!=
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
||
updatedStudent
.
get_active_grid
()
!=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_active_grid
())
{
Log
.
e
(
LOG_TAG
,
"Major config modification. Restarting is mandatory"
);
Log
.
i
(
LOG_TAG
,
"Major config modification. Restarting is mandatory"
);
PCBcontext
.
getNetService
().
restart_app
(
false
);
}
else
{
...
...
@@ -125,6 +126,10 @@ public final class PCBcontext {
public
static
void
unset_user
()
{
Log
.
e
(
PCBcontext
.
class
.
getCanonicalName
(),
"User unset. Student "
+
getPcbdb
().
getCurrentUser
().
get_name_stu
());
if
(
room
!=
null
)
room
.
exit
();
if
(
TransactionMonitor
.
getDBOnTransaction
()!=
null
)
{
Log
.
e
(
LOG_TAG
,
"Unset when transaction is active, aborting transaction"
);
TransactionMonitor
.
endTransaction
(
false
);
}
pcbdb
=
null
;
room
=
null
;
vocabulary
=
null
;
...
...
android/Pictogram/communicator/build/intermediates/incremental/mergeDevFlavorDebugResources/compile-file-map.properties
View file @
c24e7a2f
This diff is collapsed.
Click to expand it.
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/VocabularyManager.java
View file @
c24e7a2f
...
...
@@ -258,7 +258,19 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
PCBcontext
.
getNetService
().
restart_app
(
false
);
}
});
((
NetServiceTablet
)
PCBcontext
.
getNetService
().
getNetServiceDevice
()).
setInternetConnectionListener
(
new
NetServiceTablet
.
iInternetConnectionListener
()
{
@Override
public
void
update
(
final
boolean
online
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
((
ImageView
)
findViewById
(
R
.
id
.
imageConnectionOnOff
)).
setImageDrawable
(
online
?
getDrawable
(
R
.
drawable
.
application_online
)
:
getDrawable
(
R
.
drawable
.
application_offline
));
}
});
}
});
}
@Override
...
...
android/Pictogram/supervisor/src/main/java/com/yottacode/pictogram/supervisor/gui/login/LoginActivity.java
View file @
c24e7a2f
...
...
@@ -15,6 +15,7 @@ import android.widget.TextView;
import
com.yottacode.pictogram.net.ImgDownloader
;
import
com.yottacode.pictogram.supervisor.R
;
import
com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet
;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.GUITools
;
...
...
@@ -58,6 +59,19 @@ public class LoginActivity extends FragmentActivity {
startActivity
(
serialActivity
);
}
});
((
NetServiceTablet
)
PCBcontext
.
getNetService
().
getNetServiceDevice
()).
setInternetConnectionListener
(
new
NetServiceTablet
.
iInternetConnectionListener
()
{
@Override
public
void
update
(
final
boolean
online
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
((
ImageView
)
findViewById
(
R
.
id
.
imageConnectionOnOff_login
)).
setImageDrawable
(
online
?
getDrawable
(
R
.
drawable
.
application_online
)
:
getDrawable
(
R
.
drawable
.
application_offline
));
}
});
}
});
}
@Override
...
...
android/Pictogram/supervisor/src/main/res/layout/activity_login.xml
View file @
c24e7a2f
...
...
@@ -41,7 +41,13 @@
android:textColor=
"@color/BlancoApp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/imageConnectionOnOff_login"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_toLeftOf=
"@+id/loginTopbarLogout"
android:layout_centerVertical=
"true"
android:src=
"@drawable/application_online"
/>
<Button
android:id=
"@+id/loginTopbarLogout"
style=
"@android:style/Widget.Holo.Light.Button"
...
...
android/Pictogram/supervisor/src/main/res/layout/vocabulary_manager.xml
View file @
c24e7a2f
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
@@ -50,7 +51,13 @@
android:textColor=
"@color/BlancoApp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/imageConnectionOnOff"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_toLeftOf=
"@+id/vmTopbarToUserListBtn"
android:layout_alignParentTop=
"true"
android:src=
"@drawable/application_online"
/>
<Button
android:id=
"@+id/vmTopbarToUserListBtn"
style=
"@android:style/Widget.Holo.Light.Button"
...
...
@@ -105,13 +112,6 @@
</RelativeLayout>
<FrameLayout
android:id=
"@+id/fragment_container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
>
</FrameLayout>
</FrameLayout>
android/Pictogram/supervisor/src/main/res/layout/vocabulary_manager_big.xml
View file @
c24e7a2f
...
...
@@ -50,7 +50,13 @@
android:textAppearance=
"?android:attr/textAppearanceMedium"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/imageConnectionOnOff"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_toLeftOf=
"@+id/vmTopbarToUserListBtn"
android:layout_centerVertical=
"true"
android:src=
"@drawable/application_online"
/>
<Button
android:id=
"@+id/vmTopbarToUserListBtn"
style=
"@android:style/Widget.Holo.Light.Button"
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/SerialActivity.java
View file @
c24e7a2f
...
...
@@ -137,12 +137,12 @@ public class SerialActivity extends Activity {
editor
.
putString
(
"username"
,
username
);
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
))
/*
if (!username.equals("") && !password.equals(""))
try {
new UserLogin().login(username, password, SerialActivity.this, Class.forName(getString(R.string.activityAfterLogin)));
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG,e.toString());
}
}
*/
}
});
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/net/NetServiceTablet.java
View file @
c24e7a2f
...
...
@@ -22,13 +22,17 @@ import com.yottacode.pictogram.tools.PCBcontext;
*/
public
class
NetServiceTablet
implements
NetService
.
iNetServiceDevice
{
public
interface
iInternetConnectionListener
{
public
void
update
(
boolean
online
);
}
private
static
final
String
LOG_TAG
=
NetServiceTablet
.
class
.
getName
();
private
static
NotificationCompat
.
Builder
builder
;
private
VOCA
VOCA
;
int
notifyID
=
666
;
private
iInternetConnectionListener
internetConnectionListener
=
null
;
public
void
build
()
{
public
void
setInternetConnectionListener
(
iInternetConnectionListener
listener
)
{
this
.
internetConnectionListener
=
listener
;}
public
void
build
()
{
this
.
builder
=
new
NotificationCompat
.
Builder
(
PCBcontext
.
getContext
()).
setAutoCancel
(
true
).
setOngoing
(
PCBcontext
.
getContext
().
getResources
().
getBoolean
(
R
.
bool
.
NotifyAllwaysVisible
));
if
(
this
.
VOCA
!=
null
)
{
...
...
@@ -66,6 +70,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
(
NotificationManager
)
PCBcontext
.
getContext
().
getSystemService
(
PCBcontext
.
getContext
().
NOTIFICATION_SERVICE
);
mNotificationManager
.
notify
(
notifyID
,
builder
.
build
());
}
if
(
internetConnectionListener
!=
null
)
internetConnectionListener
.
update
(
updated
);
}
public
void
closeNotifyStatus
(){
NotificationManager
mNotificationManager
=
...
...
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/application_online.png
View file @
c24e7a2f
4.44 KB
|
W:
|
H:
3.66 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