issue #863, #859,#858,#850,#849, #848 closed

parent ce441482
......@@ -188,7 +188,7 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext() && user == null)
if (cursor.getInt(0) == id_stu && cursor.getInt(9) == id_sup)
user = new User(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.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));
cursor.close();
db.close();
return user;
......@@ -202,7 +202,7 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext())
if (cursor.getInt(9) == id_sup)
users.add(new User(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.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)));
cursor.close();
db.close();
return users;
......@@ -236,7 +236,7 @@ public class Device extends SQLiteOpenHelper {
if (cursor.getString(2)!=null && cursor.getString(2).equals(apwd)) {
users = new Vector<>(1);
users.add(new User(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),
User.NO_SUPERVISOR, "", "", "", "", "", "", "", ""));
User.NO_SUPERVISOR, "", "", "", "", "", "", "", "", ""));
}
else throw new LoginException("Student password incorrect", LoginException.BAD_LOGIN);
}
......@@ -263,7 +263,7 @@ public class Device extends SQLiteOpenHelper {
Vector<User> users = new Vector<User>(cursor.getCount());
while (cursor.moveToNext()) {
user = new User(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.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.add(user);
}
......@@ -292,7 +292,8 @@ public class Device extends SQLiteOpenHelper {
"'" + user.get_url_img_sup() + "'," +
"'" + user.get_gender_sup() + "'," +
"'" + user.get_lang_sup() + "'," +
"'" + user.get_tts_engine_sup() + "'" +
"'" + user.get_tts_engine_sup() + "'," +
"'" + user.get_office() + "'" +
")");
db.close();
}
......
......@@ -105,7 +105,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
cursor.moveToFirst();
try {
last_user = new User(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.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));
} catch (JSONException e) {
Log.e(LOG_TAG, e.getMessage() + " BAD FORMED JSON: " + cursor.getString(5));
System.exit(-1);
......
......@@ -24,8 +24,8 @@ public class User {
return this.get_id_sup()!=User.NO_SUPERVISOR;
}
public String getOffice() {
return null;
public String get_office() {
return office_sup;
}
public final static class JSON_STUDENT_ATTTRS{
......@@ -47,16 +47,16 @@ public class User {
private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu;
private JSONObject attributes_stu;
private Img img_sup;
private String email_sup, pwd_sup, name_sup, surname_sup, gender_sup, lang_sup, tts_engine_sup;
private String email_sup, pwd_sup, name_sup, surname_sup, gender_sup, lang_sup, tts_engine_sup, office_sup;
private boolean mirror_mode=false;
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu) throws JSONException {
this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null);
this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null,null);
}
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu,
int id_sup, String email_sup, String pwd_sup, String name_sup, String surname_sup, String url_img_sup, String gender_sup, String lang_sup, String tts_engine_sup) throws JSONException {
int id_sup, String email_sup, String pwd_sup, String name_sup, String surname_sup, String url_img_sup, String gender_sup, String lang_sup, String tts_engine_sup, String office_sup) throws JSONException {
this.img_stu=new Img(id_stu,url_img_stu,Img.STUDENT);
this.nickname_stu=nickname_stu;
this.pwd_stu=pwd_stu;
......@@ -74,6 +74,7 @@ public class User {
this.gender_sup=gender_sup;
this.lang_sup=lang_sup;
this.tts_engine_sup=tts_engine_sup;
this.office_sup=office_sup;
}
......@@ -304,6 +305,9 @@ public class User {
return get_id_sup()!=User.NO_SUPERVISOR;
}
public boolean is_teacher() {
return get_office() == null ? false : get_office().length()>0;
}
/**
......
......@@ -32,6 +32,8 @@ public class UserLogin {
private static final String TAG_GENDER = "gender";
private static final String TAG_PIC = "pic";
private static final String TAG_LANG = "lang";
private static final String TAG_OFFICE = "office";
private static final String TAG_OFFICE_NAME = "name";
private static final String TAG_ATTRIBUTES = "attributes";
//private static final String TAG_TTSENGINE = "ttsEngine";
......@@ -75,8 +77,9 @@ public class UserLogin {
GUITools.show_alert(activity, R.string.serverError);
}
Intent loginActivity = new Intent(activity, LoginActivity);
try {
Intent loginActivity = new Intent(activity, LoginActivity);
Integer su_id = user.getInt(TAG_ID);
int su_id_int = su_id.intValue();
......@@ -90,11 +93,16 @@ public class UserLogin {
loginActivity.putExtra("pic", user.getString(TAG_PIC));
loginActivity.putExtra("gender", user.getString(TAG_GENDER));
loginActivity.putExtra("lang", user.getString(TAG_LANG));
activity.startActivity(loginActivity);
} catch (JSONException e) {
GUITools.show_alert(activity, R.string.serverError, e.getMessage());
}
try {
loginActivity.putExtra("office", user.getJSONObject(TAG_OFFICE).getString(TAG_OFFICE_NAME));
} catch (JSONException e) {
loginActivity.putExtra("office", "");
}
activity.startActivity(loginActivity);
}
@Override
public void error(RestapiWrapper.HTTPException e) {
......@@ -188,7 +196,7 @@ public class UserLogin {
st_gender,
st_lang,
st_attributes,
User.NO_SUPERVISOR, "", "", "", "", "", "M", "es-es", "")
User.NO_SUPERVISOR, "", "", "", "", "", "M", "es-es", "", "")
, result.getString(TAG_TOKEN)
, pictogramActivity, activity);
} catch (JSONException e) {
......
......@@ -47,7 +47,7 @@ public class StudentTalk implements Emitter.Listener {
User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), username, surname, 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(),
user.get_lang_sup(), user.get_tts_engine_sup());
user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
for (iStudentListener listener: listeners)
listener.change(updatedUser);
......
......@@ -39,11 +39,12 @@ surname TEXT(60) NOT NULL,
url_img VARCHAR(250) NOT NULL,
gender TEXT(1) NOT NULL CHECK (gender IN ('M','F')),
lang TEXT(5) NOT NULL CHECK (lang in ('en-gb','en-us','es-es')),
tts_engine TEXT(100) NULL
tts_engine TEXT(100) NULL,
office TEXT(140) NULL
)
;--
insert into supervisor values(-1,"","","","","","M","es-es",NULL)
insert into supervisor values(-1,"","","","","","M","es-es",NULL,NULL)
;--
CREATE TABLE users (
......@@ -98,7 +99,8 @@ CREATE VIEW users_detail AS
b.url_img url_img_sup,
b.gender gender_sup,
b.lang lang_sup,
b.tts_engine tts_engine_sup
b.tts_engine tts_engine_sup,
b.office office_sup
FROM
student a, supervisor b, users
WHERE
......@@ -199,7 +201,7 @@ FOR EACH ROW
WHEN NEW.pwd_stu IS NOT NULL
BEGIN
INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup);
INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup);
END
;--
......@@ -211,7 +213,7 @@ WHEN NEW.pwd_stu IS NULL
BEGIN
INSERT OR REPLACE INTO student(id,nickname, pwd, name, surname, url_img, gender, lang, attributes)
VALUES (NEW.id_stu, NEW.nickname_stu, (SELECT pwd FROM student WHERE id=NEW.id_stu), NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup, NEW.office_sup);
INSERT OR REPLACE INTO users VALUES (NEW.id_stu,NEW.id_sup);
END
;--
......@@ -222,7 +224,7 @@ INSTEAD OF UPDATE ON users_detail
FOR EACH ROW
BEGIN
UPDATE student SET nickname=NEW.nickname_stu, pwd=NEW.pwd_stu,name=NEW.name_stu, surname=NEW.surname_stu, url_img=NEW.url_img_stu, gender=NEW.gender_stu, lang=NEW.lang_stu, attributes=NEW.attributes_stu WHERE id=NEW.id_stu;
UPDATE supervisor SET email=NEW.email_sup, pwd=NEW.pwd_sup, name=NEW.name_sup, surname=NEW.surname_sup, url_img=NEW.url_img_sup, gender=NEW.gender_sup, lang=NEW.lang_sup, tts_engine=NEW.tts_engine_sup WHERE id=NEW.id_sup;
UPDATE supervisor SET email=NEW.email_sup, pwd=NEW.pwd_sup, name=NEW.name_sup, surname=NEW.surname_sup, url_img=NEW.url_img_sup, gender=NEW.gender_sup, lang=NEW.lang_sup, tts_engine=NEW.tts_engine_sup, office=NEW.office_sup WHERE id=NEW.id_sup;
END
;--
......
......@@ -170,7 +170,7 @@ public class PictoItemViewGenerator {
redCrossImage.setVisibility(View.GONE);
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor()) {
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor() && picto!=null) {
layoutWrapper.setVisibility(View.VISIBLE);
pictoImage.setVisibility(View.VISIBLE);
layoutWrapper.setBackground(convertView.getResources()
......
......@@ -242,6 +242,15 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
}
@Override
protected void onResume() {
super.onResume();
Toast.makeText(this.getBaseContext(), PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+
(PCBcontext.getPcbdb().getCurrentUser().is_supervisor()
? " ("+ PCBcontext.getPcbdb().getCurrentUser().get_name_sup()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_sup()+")"
:"")
, Toast.LENGTH_SHORT).show();
}
private void blockNotificationBar() {
WindowManager manager = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE));
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
......@@ -702,13 +711,12 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
ViewGroup viewgroup = (ViewGroup) view.getParent();
int position = Integer.parseInt((String) event.getClipDescription().getLabel());
Log.d("Drag:", "Posición: " + position + " es categoria:" + v.getTransitionName()+" "+viewgroup.getTransitionName());
// if the view is the tape_grid_view, we accept the drag item
// Destino tape_grid_view y origen panel_grid_view
if (v == findViewById(R.id.tape_grid_view) && (viewgroup == findViewById(R.id.picto_category_grid_view) || viewgroup == findViewById(R.id.picto_main_grid_view))) {
Picto p = viewgroup == findViewById(R.id.picto_category_grid_view) ? pictoCategoryGridAdapter.getItem(position)
: pictoMainGridAdapter.getItem(position);
Log.d("Drag:", "Posición: " + position + " es categoria:" + p.is_category());
if (!p.is_category()) addPictoWord(p);
}
......@@ -1021,8 +1029,8 @@ protected void showOnlyTape(boolean onlyTape) {
break;
case MotionEvent.ACTION_UP:
if (event.getX() > firstTouchX + 150) { //izquierda a derecha
if (!student_view) {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(User.NO_SUPERVISOR);
if (!student_view || !PCBcontext.getPcbdb().getCurrentUser().is_teacher()) {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(student_view ? PCBcontext.getDevice().getLastSupId() : User.NO_SUPERVISOR);
nextActivity = intent;
} else {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(PCBcontext.getDevice().getLastSupId());
......@@ -1032,10 +1040,10 @@ protected void showOnlyTape(boolean onlyTape) {
out = R.anim.rightout;
overridePendingTransition(R.anim.leftin, R.anim.leftout);
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
if (!student_view ) {
if (!student_view && PCBcontext.getPcbdb().getCurrentUser().is_teacher() ) {
nextActivity = new Intent(this, SessionActivity.class);
} else {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(PCBcontext.getDevice().getLastSupId());
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(student_view ? PCBcontext.getDevice().getLastSupId() : User.NO_SUPERVISOR);
nextActivity = intent;
}
in = R.anim.leftin;
......
......@@ -15,7 +15,6 @@ import android.widget.TextView;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -77,7 +76,7 @@ public class LoginActivity extends FragmentActivity {
supervisorFullNameView.setText(
this.getIntent().getStringExtra("name") + " " +
this.getIntent().getStringExtra("surname"));
this.getIntent().getStringExtra("surname")+" ("+this.getIntent().getStringExtra("office")+")");
supervisorUserNameView.setText(this.getIntent().getStringExtra("email"));
final Vector<Img> imgs = new Vector<>(1);
......
......@@ -106,10 +106,10 @@ public class StudentFragmentGrid extends Fragment{
intent.getStringExtra("pic"),
intent.getStringExtra("gender"),
intent.getStringExtra("lang"),
"");
"",
intent.getStringExtra("office"));
Log.i(this.getClass().getCanonicalName(),"Loading vocabulary for "+new_user.get_name_stu()+" office:"+intent.getStringExtra("office"));
PCBcontext.getDevice().insertUser(new_user);
Log.i(this.getClass().getCanonicalName(),"Loading vocabulary for "+new_user.get_name_stu());
progressDialog=ProgressDialog.show(getActivity(), getString(R.string.loadingGrammar),
getString(R.string.userLoadingTxt), false, false);
PCBcontext.set_user(new_user, intent.getStringExtra("token"), new ImgDownloader.iImgDownloaderListener() {
......
......@@ -168,7 +168,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model));
((ListView) findViewById(R.id.session_serverlog)).setAdapter(new ArrayAdapter<String>(getBaseContext(), R.layout.list_logsessions));
StudentFullNameView.setText(student.get_name_stu() + " " + student.get_surname_stu());
StudentFullNameView.setText(student.get_name_stu() + " " + student.get_surname_stu()+" ("+student.get_office()+")");
StudentUserNameView.setText(student.get_nickname_stu());
try {
StudentPhotoView.setImageBitmap(student.get_bitmap_stu(this.getBaseContext()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment