diff --git a/SWADroid/res/layout/action_bar.xml b/SWADroid/res/layout/action_bar.xml
index dc13d1da..6b4513e9 100644
--- a/SWADroid/res/layout/action_bar.xml
+++ b/SWADroid/res/layout/action_bar.xml
@@ -157,5 +157,21 @@
android:clickable="true"
android:visibility="gone"/>
+
+
diff --git a/SWADroid/res/layout/list_item_notifications.xml b/SWADroid/res/layout/list_item_notifications.xml
index 25a5c927..2994cf35 100644
--- a/SWADroid/res/layout/list_item_notifications.xml
+++ b/SWADroid/res/layout/list_item_notifications.xml
@@ -49,6 +49,12 @@
android:layout_marginTop="3dip"
android:layout_marginRight="6dip">
+
+
+ version="16">
+
rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS);
+ for(Entity ent : rows) {
+ ent.setValue(field, value);
+ ent.save();
+ }
+ }
+
/**
* Updates a notification in database
*
@@ -1217,7 +1232,7 @@ public class DataBaseHelper {
* @param value New field value
*/
public void updateNotification(long id, String field, String value) {
- List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + id);
+ List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + id);
for(Entity ent : rows) {
ent.setValue(field, value);
ent.save();
@@ -1231,8 +1246,9 @@ public class DataBaseHelper {
* @param actual Updated notification
*/
public void updateNotification(long id, SWADNotification actual) {
- List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + id);
- long newID = actual.getId();
+ List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + id);
+ long notifCode = actual.getId();
+ long eventCode = actual.getEventCode();
String eventType = crypto.encrypt(actual.getEventType());
String eventTime = String.valueOf(actual.getEventTime());
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
@@ -1247,7 +1263,8 @@ public class DataBaseHelper {
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
for(Entity ent : rows) {
- ent.setValue("id", newID);
+ ent.setValue("notifCode", notifCode);
+ ent.setValue("eventCode", eventCode);
ent.setValue("eventType", eventType);
ent.setValue("eventTime", eventTime);
ent.setValue("userSurname1", userSurname1);
@@ -1271,8 +1288,9 @@ public class DataBaseHelper {
* @param actual Updated notification
*/
public void updateNotification(SWADNotification prev, SWADNotification actual) {
- List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + prev.getId());
- long newID = actual.getId();
+ List rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + prev.getId());
+ long notifCode = actual.getId();
+ long eventCode = actual.getEventCode();
String eventType = crypto.encrypt(actual.getEventType());
String eventTime = String.valueOf(actual.getEventTime());
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
@@ -1287,7 +1305,8 @@ public class DataBaseHelper {
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
for(Entity ent : rows) {
- ent.setValue("id", newID);
+ ent.setValue("notifCode", notifCode);
+ ent.setValue("eventCode", eventCode);
ent.setValue("eventType", eventType);
ent.setValue("eventTime", eventTime);
ent.setValue("userSurname1", userSurname1);
@@ -1497,7 +1516,6 @@ public class DataBaseHelper {
return false;
}
- @SuppressWarnings("unused")
private boolean updateRelationship(Pair tables, Pair idsTables, String relationTable, Pair remainField, Pair changedField) {
@@ -1524,7 +1542,6 @@ public class DataBaseHelper {
/**
* Updates an existing group type
*/
- @SuppressWarnings("unused")
private boolean updateGroupType(GroupType prv, GroupType current) {
List rows = db.getEntityList(Constants.DB_TABLE_GROUP_TYPES, "id=" + prv.getId());
boolean returnValue = true;
@@ -1559,8 +1576,8 @@ public class DataBaseHelper {
removeRow(Constants.DB_TABLE_GROUPS, g.getId());
//Remove also relationships with courses and group types
- removeAllRow(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", g.getId());
- removeAllRow(Constants.DB_TABLE_GROUPS_COURSES, "grpCod", g.getId());
+ removeAllRows(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", g.getId());
+ removeAllRows(Constants.DB_TABLE_GROUPS_COURSES, "grpCod", g.getId());
}
/**
@@ -1580,7 +1597,7 @@ public class DataBaseHelper {
* @param fieldName Name field to search
* @param value Value field of row to be removed
*/
- void removeAllRow(String table, String fieldName, long value) {
+ void removeAllRows(String table, String fieldName, long value) {
List rows = db.getEntityList(table, fieldName + "= " + value);
for (Entity ent : rows) {
ent.delete();
@@ -1592,7 +1609,7 @@ public class DataBaseHelper {
*
* @param p PairTable to be removed
*/
- public void removePairTable(@SuppressWarnings("rawtypes") PairTable p) {
+ public void removePairTable(PairTable, ?> p) {
String table = p.getTable();
Integer first = (Integer) p.getFirst();
Integer second = (Integer) p.getSecond();
@@ -1635,7 +1652,7 @@ public class DataBaseHelper {
* @return Last time the test was updated
*/
public String getTimeOfLastTestUpdate(long selectedCourseCode) {
- String where = "id=" + selectedCourseCode;
+ String where = "notifCode=" + selectedCourseCode;
String orderby = null;
List rows = db.getEntityList(Constants.DB_TABLE_TEST_CONFIG, where, orderby);
String f = "0";
@@ -1863,10 +1880,6 @@ public class DataBaseHelper {
ent.save();
}
}
-
- void markNotificationAsSeenLocally(String notificationCode) {
-
- }
/**
* Empty table from database
@@ -1897,23 +1910,7 @@ public class DataBaseHelper {
* Clean data of all tables from database. Removes users photos from external storage
*/
public void cleanTables() {
- emptyTable(Constants.DB_TABLE_NOTIFICATIONS);
- emptyTable(Constants.DB_TABLE_COURSES);
- emptyTable(Constants.DB_TABLE_TEST_QUESTION_ANSWERS);
- emptyTable(Constants.DB_TABLE_TEST_QUESTION_TAGS);
- emptyTable(Constants.DB_TABLE_TEST_QUESTIONS_COURSE);
- emptyTable(Constants.DB_TABLE_TEST_ANSWERS);
- emptyTable(Constants.DB_TABLE_TEST_CONFIG);
- emptyTable(Constants.DB_TABLE_TEST_QUESTIONS);
- emptyTable(Constants.DB_TABLE_TEST_TAGS);
- emptyTable(Constants.DB_TABLE_USERS_COURSES);
- emptyTable(Constants.DB_TABLE_USERS);
- emptyTable(Constants.DB_TABLE_GROUPS_COURSES);
- emptyTable(Constants.DB_TABLE_GROUPS);
- emptyTable(Constants.DB_TABLE_PRACTICE_SESSIONS);
- emptyTable(Constants.DB_TABLE_ROLLCALL);
- emptyTable(Constants.DB_TABLE_GROUP_TYPES);
- emptyTable(Constants.DB_TABLE_GROUPS_GROUPTYPES);
+ db.emptyTables();
compactDB();
// Removes users photos from external storage (Android 2.2 or higher only)
@@ -1969,11 +1966,6 @@ public class DataBaseHelper {
*/
public void upgradeDB(Context context) {
int dbVersion = db.getDB().getVersion();
- boolean found = false;
- int i = 0;
- int rowsAffected;
- ContentValues fields;
-
/*
* Modify database keeping data:
* 1. Create temporary table __DB_TABLE_GROUPS (with the new model)
@@ -1986,57 +1978,17 @@ public class DataBaseHelper {
* Just to modify database without to keep data just 7,6.
*
* */
-
-
- /* From version 11 to 12
- * changes on courses table:
- * - old field name is erased
- * The rest of the changes are only new fields and they are added automatic by Dataframework. */
- if (dbVersion < 12) {
- Cursor dbCursor = db.getDB().query(Constants.DB_TABLE_COURSES, null, null, null, null, null, null);
- String[] columnNames = dbCursor.getColumnNames();
- while (i < columnNames.length && !found) {
- if (columnNames[i].compareTo("name") == 0) found = true;
- ++i;
- }
- if (found) {
- //without to keep data
- db.getDB().execSQL("DROP TABLE " + Constants.DB_TABLE_COURSES + ";");//+
- db.getDB().execSQL("CREATE TABLE " + Constants.DB_TABLE_COURSES
- + " (_id integer primary key autoincrement, id long, userRole integer,shortName text, fullName text);");
- }
-
- /* version 12 - 13
- * changes on groups table:
- * - old field groupCode is now id
- * - old field groupTypeCode is erased
- * - old field groupTypeName is erased
- * The rest of the changes are only new fields and they are added automatic by Dataframework.
- * */
- } else if (dbVersion < 13) {
- Cursor dbCursor = db.getDB().query(Constants.DB_TABLE_GROUPS, null, null, null, null, null, null);
- String[] columnNames = dbCursor.getColumnNames();
- while (i < columnNames.length && !found) {
- if (columnNames[i].equals("groupCode")) found = true;
- ++i;
- }
- if (found) {
- //without to keep data
- db.getDB().execSQL("DROP TABLE " + Constants.DB_TABLE_GROUPS + ";");
- db.getDB().execSQL("CREATE TABLE " + Constants.DB_TABLE_GROUPS + " (_id integer primary key autoincrement, id long, groupName text, maxStudents integer,"
- + " students integer, open integer, fileZones integer, member integer); ");
- }
-
- /* version 14-15
+
+ /* version 15-16
* changes on notifications table:
- * - new field seenLocal initialized to true
- * - new field seenRemote initialized to true
+ * - new field notifCode
+ * - changed field id to eventCode
* */
- } else if (dbVersion < 15) {
- fields = new ContentValues();
- fields.put("seenLocal", Utils.parseBoolString(true));
- fields.put("seenRemote", Utils.parseBoolString(true));
- rowsAffected = db.getDB().update(Constants.DB_TABLE_NOTIFICATIONS, fields, null, null);
+ if (dbVersion == 16) {
+ //without keeping data
+ db.getDB().execSQL("DROP TABLE " + Constants.DB_TABLE_NOTIFICATIONS + ";");
+ db.getDB().execSQL("CREATE TABLE " + Constants.DB_TABLE_NOTIFICATIONS + " (_id integer primary key autoincrement, notifCode long, eventCode long, eventType text, eventTime text,"
+ + " userSurname1 text, userSurname2 text, userFirstname text, userPhoto text, location text, summary text, status text, content text, seenLocal text, seenRemote text); ");
}
compactDB();
diff --git a/SWADroid/src/es/ugr/swad/swadroid/model/SWADNotification.java b/SWADroid/src/es/ugr/swad/swadroid/model/SWADNotification.java
index 57b80b49..816b38e0 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/model/SWADNotification.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/model/SWADNotification.java
@@ -20,8 +20,6 @@ package es.ugr.swad.swadroid.model;
import org.ksoap2.serialization.PropertyInfo;
-import es.ugr.swad.swadroid.utils.Utils;
-
import java.util.Hashtable;
/**
@@ -30,6 +28,10 @@ import java.util.Hashtable;
* @author Juan Miguel Boyero Corral *
*/
public class SWADNotification extends Model {
+ /**
+ * Event id (not unique)
+ */
+ private long eventCode;
/**
* Notification type
*/
@@ -79,6 +81,7 @@ public class SWADNotification extends Model {
*/
private boolean seenRemote;
private static final PropertyInfo PI_id = new PropertyInfo();
+ private static final PropertyInfo PI_eventCode = new PropertyInfo();
private static final PropertyInfo PI_eventType = new PropertyInfo();
private static final PropertyInfo PI_eventTime = new PropertyInfo();
private static final PropertyInfo PI_userSurname1 = new PropertyInfo();
@@ -93,6 +96,7 @@ public class SWADNotification extends Model {
private static PropertyInfo[] PI_PROP_ARRAY =
{
PI_id,
+ PI_eventCode,
PI_eventType,
PI_eventTime,
PI_userSurname1,
@@ -106,7 +110,8 @@ public class SWADNotification extends Model {
};
/**
- * @param id Notification id
+ * @param id Notification id (unique)
+ * @param eventCode Event id (not unique)
* @param eventType Notification type
* @param eventTime Notification timestamp
* @param userSurname1 Sender first surname
@@ -119,12 +124,13 @@ public class SWADNotification extends Model {
* @param seenLocal Notification has been seen locally
* @param seenRemote Notification has been seen in SWAD
*/
- public SWADNotification(long id, String eventType, long eventTime,
+ public SWADNotification(long id, long eventCode, String eventType, long eventTime,
String userSurname1, String userSurname2, String userFirstName,
String userPhoto, String location, String summary, int status,
String content, boolean seenLocal, boolean seenRemote) {
super(id);
+ this.eventCode = eventCode;
this.eventType = eventType;
this.eventTime = eventTime;
this.userSurname1 = userSurname1;
@@ -139,6 +145,24 @@ public class SWADNotification extends Model {
this.seenRemote = seenRemote;
}
+ /**
+ * Gets event id
+ *
+ * @return Event id
+ */
+ public long getEventCode() {
+ return eventCode;
+ }
+
+ /**
+ * Sets event id
+ *
+ * @param eventCode Event id
+ */
+ public void setEventCode(long eventCode) {
+ this.eventCode = eventCode;
+ }
+
/**
* Gets notification type
*
@@ -359,106 +383,116 @@ public class SWADNotification extends Model {
this.seenRemote = seenRemote;
}
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
- return "SWADNotification [eventType=" + eventType + ", eventTime="
- + eventTime + ", userSurname1=" + userSurname1
- + ", userSurname2=" + userSurname2 + ", userFirstName="
- + userFirstName + ", userPhoto=" + userPhoto + ", location="
- + location + ", summary=" + summary + ", status=" + status
- + ", content=" + content + ", seenLocal=" + seenLocal
- + ", seenRemote=" + seenRemote + "]";
+ return "SWADNotification [notifCode=" + getId() + ", eventCode=" + eventCode + ", eventType="
+ + eventType + ", eventTime=" + eventTime + ", userSurname1="
+ + userSurname1 + ", userSurname2=" + userSurname2
+ + ", userFirstName=" + userFirstName + ", userPhoto="
+ + userPhoto + ", location=" + location + ", summary=" + summary
+ + ", status=" + status + ", content=" + content
+ + ", seenLocal=" + seenLocal + ", seenRemote=" + seenRemote
+ + "]";
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((content == null) ? 0 : content.hashCode());
+ result = prime * result + (int) (eventCode ^ (eventCode >>> 32));
+ result = prime * result + (int) (eventTime ^ (eventTime >>> 32));
+ result = prime * result
+ + ((eventType == null) ? 0 : eventType.hashCode());
+ result = prime * result
+ + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + (seenLocal ? 1231 : 1237);
+ result = prime * result + (seenRemote ? 1231 : 1237);
+ result = prime * result + status;
+ result = prime * result + ((summary == null) ? 0 : summary.hashCode());
+ result = prime * result
+ + ((userFirstName == null) ? 0 : userFirstName.hashCode());
+ result = prime * result
+ + ((userPhoto == null) ? 0 : userPhoto.hashCode());
+ result = prime * result
+ + ((userSurname1 == null) ? 0 : userSurname1.hashCode());
+ result = prime * result
+ + ((userSurname2 == null) ? 0 : userSurname2.hashCode());
+ return result;
}
/* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((content == null) ? 0 : content.hashCode());
- result = prime * result + (int) (eventTime ^ (eventTime >>> 32));
- result = prime * result
- + ((eventType == null) ? 0 : eventType.hashCode());
- result = prime * result
- + ((location == null) ? 0 : location.hashCode());
- result = prime * result + status;
- result = prime * result + ((summary == null) ? 0 : summary.hashCode());
- result = prime * result
- + ((userFirstName == null) ? 0 : userFirstName.hashCode());
- result = prime * result
- + ((userPhoto == null) ? 0 : userPhoto.hashCode());
- result = prime * result
- + ((userSurname1 == null) ? 0 : userSurname1.hashCode());
- result = prime * result
- + ((userSurname2 == null) ? 0 : userSurname2.hashCode());
- return result;
- }
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SWADNotification other = (SWADNotification) obj;
+ if (content == null) {
+ if (other.content != null)
+ return false;
+ } else if (!content.equals(other.content))
+ return false;
+ if (eventCode != other.eventCode)
+ return false;
+ if (eventTime != other.eventTime)
+ return false;
+ if (eventType == null) {
+ if (other.eventType != null)
+ return false;
+ } else if (!eventType.equals(other.eventType))
+ return false;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (seenLocal != other.seenLocal)
+ return false;
+ if (seenRemote != other.seenRemote)
+ return false;
+ if (status != other.status)
+ return false;
+ if (summary == null) {
+ if (other.summary != null)
+ return false;
+ } else if (!summary.equals(other.summary))
+ return false;
+ if (userFirstName == null) {
+ if (other.userFirstName != null)
+ return false;
+ } else if (!userFirstName.equals(other.userFirstName))
+ return false;
+ if (userPhoto == null) {
+ if (other.userPhoto != null)
+ return false;
+ } else if (!userPhoto.equals(other.userPhoto))
+ return false;
+ if (userSurname1 == null) {
+ if (other.userSurname1 != null)
+ return false;
+ } else if (!userSurname1.equals(other.userSurname1))
+ return false;
+ if (userSurname2 == null) {
+ if (other.userSurname2 != null)
+ return false;
+ } else if (!userSurname2.equals(other.userSurname2))
+ return false;
+ return true;
+ }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- SWADNotification other = (SWADNotification) obj;
- if (content == null) {
- if (other.content != null)
- return false;
- } else if (!content.equals(other.content))
- return false;
- if (eventTime != other.eventTime)
- return false;
- if (eventType == null) {
- if (other.eventType != null)
- return false;
- } else if (!eventType.equals(other.eventType))
- return false;
- if (location == null) {
- if (other.location != null)
- return false;
- } else if (!location.equals(other.location))
- return false;
- if (status != other.status)
- return false;
- if (summary == null) {
- if (other.summary != null)
- return false;
- } else if (!summary.equals(other.summary))
- return false;
- if (userFirstName == null) {
- if (other.userFirstName != null)
- return false;
- } else if (!userFirstName.equals(other.userFirstName))
- return false;
- if (userPhoto == null) {
- if (other.userPhoto != null)
- return false;
- } else if (!userPhoto.equals(other.userPhoto))
- return false;
- if (userSurname1 == null) {
- if (other.userSurname1 != null)
- return false;
- } else if (!userSurname1.equals(other.userSurname1))
- return false;
- if (userSurname2 == null) {
- if (other.userSurname2 != null)
- return false;
- } else if (!userSurname2.equals(other.userSurname2))
- return false;
- return true;
- }
-
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.ksoap2.serialization.KvmSerializable#getProperty(int)
*/
public Object getProperty(int param) {
@@ -468,33 +502,36 @@ public class SWADNotification extends Model {
object = this.getId();
break;
case 1:
- object = eventType;
+ object = eventCode;
break;
case 2:
- object = eventTime;
+ object = eventType;
break;
case 3:
- object = userSurname1;
+ object = eventTime;
break;
case 4:
- object = userSurname2;
+ object = userSurname1;
break;
case 5:
- object = userFirstName;
+ object = userSurname2;
break;
case 6:
- object = userPhoto;
+ object = userFirstName;
break;
case 7:
- object = location;
+ object = userPhoto;
break;
case 8:
- object = summary;
+ object = location;
break;
case 9:
- object = status;
+ object = summary;
break;
case 10:
+ object = status;
+ break;
+ case 11:
object = content;
break;
}
@@ -506,7 +543,7 @@ public class SWADNotification extends Model {
* @see org.ksoap2.serialization.KvmSerializable#getPropertyCount()
*/
public int getPropertyCount() {
- return 9;
+ return 10;
}
/* (non-Javadoc)
@@ -519,42 +556,46 @@ public class SWADNotification extends Model {
propertyInfo.name = "id";
break;
case 1:
+ propertyInfo.type = PropertyInfo.LONG_CLASS;
+ propertyInfo.name = "eventCode";
+ break;
+ case 2:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "eventType";
break;
- case 2:
+ case 3:
propertyInfo.type = PropertyInfo.LONG_CLASS;
propertyInfo.name = "eventTime";
break;
- case 3:
+ case 4:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "userSurname1";
break;
- case 4:
+ case 5:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "userSurname2";
break;
- case 5:
+ case 6:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "userFirstName";
break;
- case 6:
+ case 7:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "userPhoto";
break;
- case 7:
+ case 8:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "location";
break;
- case 8:
+ case 9:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "summary";
break;
- case 9:
+ case 10:
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
propertyInfo.name = "status";
break;
- case 10:
+ case 11:
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "content";
break;
@@ -570,33 +611,36 @@ public class SWADNotification extends Model {
this.setId((Long) obj);
break;
case 1:
- eventType = (String) obj;
+ eventCode = (Long) obj;
break;
case 2:
- eventTime = (Long) obj;
+ eventType = (String) obj;
break;
case 3:
- userSurname1 = (String) obj;
+ eventTime = (Long) obj;
break;
case 4:
- userSurname2 = (String) obj;
+ userSurname1 = (String) obj;
break;
case 5:
- userFirstName = (String) obj;
+ userSurname2 = (String) obj;
break;
case 6:
- userPhoto = (String) obj;
+ userFirstName = (String) obj;
break;
case 7:
- location = (String) obj;
+ userPhoto = (String) obj;
break;
case 8:
- summary = (String) obj;
+ location = (String) obj;
break;
case 9:
- status = (Integer) obj;
+ summary = (String) obj;
break;
case 10:
+ status = (Integer) obj;
+ break;
+ case 11:
content = (String) obj;
break;
}
diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/Messages.java b/SWADroid/src/es/ugr/swad/swadroid/modules/Messages.java
index 82c34e92..2fca518d 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/modules/Messages.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/modules/Messages.java
@@ -57,7 +57,7 @@ public class Messages extends Module {
/**
* Message code
*/
- private Long notificationCode;
+ private Long eventCode;
/**
* Message's receivers
*/
@@ -136,7 +136,7 @@ public class Messages extends Module {
b.setOnClickListener(positiveClickListener);
- if (notificationCode != 0) {
+ if (eventCode != 0) {
subject = getIntent().getStringExtra("summary");
subjectText.setText("Re: " + subject);
@@ -161,7 +161,7 @@ public class Messages extends Module {
protected void onStart() {
super.onStart();
- notificationCode = getIntent().getLongExtra("notificationCode", 0);
+ eventCode = getIntent().getLongExtra("eventCode", 0);
messageDialog = DialogFactory.createPositiveNegativeDialog(this,
R.layout.dialog_messages,
@@ -238,7 +238,7 @@ public class Messages extends Module {
createRequest();
addParam("wsKey", Constants.getLoggedUser().getWsKey());
- addParam("messageCode", notificationCode.intValue());
+ addParam("messageCode", eventCode.intValue());
addParam("to", receivers);
addParam("subject", subject);
addParam("body", body);
@@ -310,7 +310,7 @@ public class Messages extends Module {
*/
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
- notificationCode = savedInstanceState.getLong("notificationCode");
+ eventCode = savedInstanceState.getLong("eventCode");
receivers = savedInstanceState.getString("receivers");
receiversNames = savedInstanceState.getString("receiversNames");
subject = savedInstanceState.getString("subject");
@@ -328,7 +328,7 @@ public class Messages extends Module {
protected void onSaveInstanceState(Bundle outState) {
readData();
- outState.putLong("notificationCode", notificationCode);
+ outState.putLong("eventCode", eventCode);
outState.putString("receivers", receivers);
outState.putString("receiversNames", receiversNames);
outState.putString("subject", subject);
diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationItem.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationItem.java
index c5487253..c23955f3 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationItem.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationItem.java
@@ -40,7 +40,8 @@ import es.ugr.swad.swadroid.utils.Utils;
* @author Juan Miguel Boyero Corral
*/
public class NotificationItem extends MenuActivity {
- private Long notificationCode;
+ private Long notifCode;
+ private Long eventCode;
private String sender;
private String userPhoto;
private String course;
@@ -85,7 +86,8 @@ public class NotificationItem extends MenuActivity {
replyButton.setVisibility(View.GONE);
}
- //notificationCode =
+ notifCode = Long.valueOf(this.getIntent().getStringExtra("notifCode"));
+ eventCode = Long.valueOf(this.getIntent().getStringExtra("eventCode"));
sender = this.getIntent().getStringExtra("sender");
userPhoto = this.getIntent().getStringExtra("userPhoto");
course = this.getIntent().getStringExtra("course");
@@ -119,8 +121,7 @@ public class NotificationItem extends MenuActivity {
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
//Set notification as seen locally
- notificationCode = Long.valueOf(this.getIntent().getStringExtra("notificationCode"));
- dbHelper.updateNotification(notificationCode, "seenLocal", Utils.parseBoolString(true));
+ dbHelper.updateNotification(notifCode, "seenLocal", Utils.parseBoolString(true));
}
/**
@@ -129,9 +130,8 @@ public class NotificationItem extends MenuActivity {
* @param v Actual view
*/
public void onReplyMessageClick(View v) {
- notificationCode = Long.valueOf(this.getIntent().getStringExtra("notificationCode"));
Intent activity = new Intent(this, Messages.class);
- activity.putExtra("notificationCode", notificationCode);
+ activity.putExtra("eventCode", eventCode);
activity.putExtra("summary", summary);
startActivity(activity);
}
diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java
index 5032ff50..b2cc823c 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/Notifications.java
@@ -37,6 +37,7 @@ import es.ugr.swad.swadroid.R;
import es.ugr.swad.swadroid.gui.AlertNotification;
import es.ugr.swad.swadroid.model.SWADNotification;
import es.ugr.swad.swadroid.modules.Module;
+import es.ugr.swad.swadroid.utils.Utils;
import org.ksoap2.serialization.SoapObject;
import org.xmlpull.v1.XmlPullParserException;
@@ -112,6 +113,7 @@ public class Notifications extends Module {
private OnItemClickListener clickListener = new OnItemClickListener() {
public void onItemClick(AdapterView> av, View v, int position, long rowId) {
//adapter.toggleContentVisibility(position);
+ TextView id = (TextView) v.findViewById(R.id.notifCode);
TextView code = (TextView) v.findViewById(R.id.eventCode);
TextView type = (TextView) v.findViewById(R.id.eventType);
TextView userPhoto = (TextView) v.findViewById(R.id.eventUserPhoto);
@@ -123,7 +125,8 @@ public class Notifications extends Module {
TextView time = (TextView) v.findViewById(R.id.eventTime);
Intent activity = new Intent(getApplicationContext(), NotificationItem.class);
- activity.putExtra("notificationCode", code.getText().toString());
+ activity.putExtra("notifCode", id.getText().toString());
+ activity.putExtra("eventCode", code.getText().toString());
activity.putExtra("notificationType", type.getText().toString());
activity.putExtra("userPhoto", userPhoto.getText().toString());
activity.putExtra("sender", sender.getText().toString());
@@ -178,6 +181,7 @@ public class Notifications extends Module {
this.findViewById(R.id.courseSelectedText).setVisibility(View.GONE);
this.findViewById(R.id.groupSpinner).setVisibility(View.GONE);
+ this.findViewById(R.id.markAllRead).setVisibility(View.VISIBLE);
image = (ImageView) this.findViewById(R.id.moduleIcon);
image.setBackgroundResource(R.drawable.bell);
@@ -246,6 +250,16 @@ public class Notifications extends Module {
onError();
}
+ /**
+ * Launches an action when markAllRead button is pushed
+ *
+ * @param v Actual view
+ */
+ public void onMarkAllReadClick(View v) {
+ dbHelper.updateAllNotifications("seenLocal", Utils.parseBoolString(true));
+ refreshScreen();
+ }
+
/* (non-Javadoc)
* @see es.ugr.swad.swadroid.modules.Module#onResume()
*/
@@ -299,7 +313,8 @@ public class Notifications extends Module {
notifCount = soap.getPropertyCount();
for (int i = 0; i < notifCount; i++) {
SoapObject pii = (SoapObject) soap.getProperty(i);
- Long notificationCode = Long.valueOf(pii.getProperty("notificationCode").toString());
+ Long notifCode = Long.valueOf(pii.getProperty("notifCode").toString());
+ Long eventCode = Long.valueOf(pii.getProperty("notificationCode").toString());
String eventType = pii.getProperty("eventType").toString();
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
String userSurname1 = pii.getProperty("userSurname1").toString();
@@ -312,7 +327,7 @@ public class Notifications extends Module {
String content = pii.getProperty("content").toString();
//TODO Add "notification seen" info from SWAD
- SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, userPhoto, location, summary, status, content, false, false);
+ SWADNotification n = new SWADNotification(notifCode, eventCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, userPhoto, location, summary, status, content, false, false);
dbHelper.insertNotification(n);
if(isDebuggable)
diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java
index 0145f0f5..25ef17f5 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsCursorAdapter.java
@@ -99,7 +99,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
@Override
public void bindView(View view, Context context, Cursor cursor) {
- final Long notificationCode = cursor.getLong(cursor.getColumnIndex("id"));
+ final Long notifCode = cursor.getLong(cursor.getColumnIndex("notifCode"));
+ final Long eventCode = cursor.getLong(cursor.getColumnIndex("eventCode"));
final String userPhoto = cursor.getString(cursor.getColumnIndex("userPhoto"));
long unixTime;
String type = "";
@@ -123,7 +124,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
}
view.setScrollContainer(false);
- TextView eventCode = (TextView) view.findViewById(R.id.eventCode);
+ TextView notifCodeHided = (TextView) view.findViewById(R.id.notifCode);
+ TextView eventCodeHided = (TextView) view.findViewById(R.id.eventCode);
TextView eventUserPhoto = (TextView) view.findViewById(R.id.eventUserPhoto);
TextView eventType = (TextView) view.findViewById(R.id.eventType);
TextView eventDate = (TextView) view.findViewById(R.id.eventDate);
@@ -146,7 +148,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
};*/
if (eventType != null) {
- eventCode.setText(notificationCode.toString());
+ notifCodeHided.setText(notifCode.toString());
+ eventCodeHided.setText(eventCode.toString());
eventUserPhoto.setText(crypto.decrypt(userPhoto));
type = crypto.decrypt(cursor.getString(cursor.getColumnIndex("eventType")));
//messageReplyButton.setVisibility(View.GONE);
diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java
index 2c5e9852..b639f583 100644
--- a/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java
+++ b/SWADroid/src/es/ugr/swad/swadroid/modules/notifications/NotificationsSyncAdapterService.java
@@ -339,8 +339,9 @@ public class NotificationsSyncAdapterService extends Service {
SoapObject soap = (SoapObject) res.get(1);
notifCount = soap.getPropertyCount();
for (int i = 0; i < notifCount; i++) {
- SoapObject pii = (SoapObject) soap.getProperty(i);
- Long notificationCode = Long.valueOf(pii.getProperty("notificationCode").toString());
+ SoapObject pii = (SoapObject) soap.getProperty(i);
+ Long notifCode = Long.valueOf(pii.getProperty("notifCode").toString());
+ Long eventCode = Long.valueOf(pii.getProperty("notificationCode").toString());
String eventType = pii.getProperty("eventType").toString();
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
String userSurname1 = pii.getProperty("userSurname1").toString();
@@ -353,7 +354,7 @@ public class NotificationsSyncAdapterService extends Service {
String content = pii.getProperty("content").toString();
//TODO Add "notification seen" info from SWAD
- SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, userPhoto, location, summary, status, content, false, false);
+ SWADNotification n = new SWADNotification(notifCode, eventCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, userPhoto, location, summary, status, content, false, false);
dbHelper.insertNotification(n);
//Log.d(TAG, n.toString());