Updated Notifications table and added "mark all notifications as read"
feature (locally) TODO: Change markAllRead icon and send info to SWAD
This commit is contained in:
parent
6dd6df0815
commit
332b21849c
|
@ -157,5 +157,21 @@
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/markAllRead"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignWithParentIfMissing="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:src="@drawable/title_refresh"
|
||||||
|
android:onClick="onMarkAllReadClick"
|
||||||
|
android:background="@drawable/title_button"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:paddingLeft="3dip"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@
|
||||||
android:layout_marginTop="3dip"
|
android:layout_marginTop="3dip"
|
||||||
android:layout_marginRight="6dip">
|
android:layout_marginRight="6dip">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/notifCode"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/eventCode"
|
android:id="@+id/eventCode"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<database
|
<database
|
||||||
name="swadroid_db_crypt"
|
name="swadroid_db_crypt"
|
||||||
version="15">
|
version="16">
|
||||||
|
|
||||||
<table
|
<table
|
||||||
name="courses"
|
name="courses"
|
||||||
|
@ -31,7 +31,13 @@
|
||||||
new-in-version="3"
|
new-in-version="3"
|
||||||
to-string="%name%">
|
to-string="%name%">
|
||||||
<field
|
<field
|
||||||
name="id"
|
name="notifCode"
|
||||||
|
new-in-version="16"
|
||||||
|
obligatory="true"
|
||||||
|
type="long"/>
|
||||||
|
<field
|
||||||
|
name="eventCode"
|
||||||
|
new-in-version="16"
|
||||||
obligatory="true"
|
obligatory="true"
|
||||||
type="long"/>
|
type="long"/>
|
||||||
<field
|
<field
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class SWADMain extends MenuExpandableListActivity {
|
||||||
startActivityForResult(activity, Constants.TESTS_REQUEST_CODE);
|
startActivityForResult(activity, Constants.TESTS_REQUEST_CODE);
|
||||||
} else if (keyword.equals(getString(R.string.messagesModuleLabel))) {
|
} else if (keyword.equals(getString(R.string.messagesModuleLabel))) {
|
||||||
activity = new Intent(getBaseContext(), Messages.class);
|
activity = new Intent(getBaseContext(), Messages.class);
|
||||||
activity.putExtra("notificationCode", Long.valueOf(0));
|
activity.putExtra("eventCode", Long.valueOf(0));
|
||||||
startActivityForResult(activity, Constants.MESSAGES_REQUEST_CODE);
|
startActivityForResult(activity, Constants.MESSAGES_REQUEST_CODE);
|
||||||
} else if (keyword.equals(getString(R.string.noticesModuleLabel))) {
|
} else if (keyword.equals(getString(R.string.noticesModuleLabel))) {
|
||||||
activity = new Intent(getBaseContext(), Notices.class);
|
activity = new Intent(getBaseContext(), Notices.class);
|
||||||
|
@ -315,25 +315,6 @@ public class SWADMain extends MenuExpandableListActivity {
|
||||||
prefs.setSyncTime(String.valueOf(Constants.DEFAULT_SYNC_TIME));
|
prefs.setSyncTime(String.valueOf(Constants.DEFAULT_SYNC_TIME));
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the app is updating from an unencrypted version, encrypt already downloaded notifications
|
|
||||||
if (lastVersion < 45) {
|
|
||||||
dbHelper.encryptNotifications();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the app is updating from the bugged encrypted version,
|
|
||||||
* re-encrypt the notifications using the new method
|
|
||||||
*/
|
|
||||||
} else if (lastVersion == 45) {
|
|
||||||
dbHelper.reencryptNotifications();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Configure automatic synchronization
|
|
||||||
if (lastVersion < 49) {
|
|
||||||
activity = new Intent(getBaseContext(), AccountAuthenticator.class);
|
|
||||||
startActivity(activity);
|
|
||||||
SyncUtils.addPeriodicSync(Constants.AUTHORITY, Bundle.EMPTY, Constants.DEFAULT_SYNC_TIME, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Configure automatic synchronization
|
//Configure automatic synchronization
|
||||||
if(Preferences.isSyncEnabled()) {
|
if(Preferences.isSyncEnabled()) {
|
||||||
activity = new Intent(getBaseContext(), AccountAuthenticator.class);
|
activity = new Intent(getBaseContext(), AccountAuthenticator.class);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package es.ugr.swad.swadroid.model;
|
package es.ugr.swad.swadroid.model;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
|
@ -215,7 +214,8 @@ public class DataBaseHelper {
|
||||||
ent.getInt(params.getFirst()),
|
ent.getInt(params.getFirst()),
|
||||||
ent.getInt(params.getSecond()));
|
ent.getInt(params.getSecond()));
|
||||||
} else if (table.equals(Constants.DB_TABLE_NOTIFICATIONS)) {
|
} else if (table.equals(Constants.DB_TABLE_NOTIFICATIONS)) {
|
||||||
o = new SWADNotification(ent.getInt("id"),
|
o = new SWADNotification(ent.getInt("notifCode"),
|
||||||
|
ent.getInt("eventCode"),
|
||||||
crypto.decrypt(ent.getString("eventType")),
|
crypto.decrypt(ent.getString("eventType")),
|
||||||
ent.getLong("eventTime"),
|
ent.getLong("eventTime"),
|
||||||
crypto.decrypt(ent.getString("userSurname1")),
|
crypto.decrypt(ent.getString("userSurname1")),
|
||||||
|
@ -755,7 +755,8 @@ public class DataBaseHelper {
|
||||||
String eventTime = String.valueOf(n.getEventTime());
|
String eventTime = String.valueOf(n.getEventTime());
|
||||||
String status = String.valueOf(n.getStatus());
|
String status = String.valueOf(n.getStatus());
|
||||||
|
|
||||||
ent.setValue("id", n.getId());
|
ent.setValue("notifCode", n.getId());
|
||||||
|
ent.setValue("eventCode", n.getEventCode());
|
||||||
ent.setValue("eventType", crypto.encrypt(n.getEventType()));
|
ent.setValue("eventType", crypto.encrypt(n.getEventType()));
|
||||||
ent.setValue("eventTime", eventTime);
|
ent.setValue("eventTime", eventTime);
|
||||||
ent.setValue("userSurname1", crypto.encrypt(n.getUserSurname1()));
|
ent.setValue("userSurname1", crypto.encrypt(n.getUserSurname1()));
|
||||||
|
@ -1065,8 +1066,8 @@ public class DataBaseHelper {
|
||||||
if (table.compareTo(Constants.DB_TABLE_GROUP_TYPES) == 0) {
|
if (table.compareTo(Constants.DB_TABLE_GROUP_TYPES) == 0) {
|
||||||
for (Model anObsoleteModel : obsoleteModel) {
|
for (Model anObsoleteModel : obsoleteModel) {
|
||||||
long code = anObsoleteModel.getId();
|
long code = anObsoleteModel.getId();
|
||||||
removeAllRow(table, "id", code);
|
removeAllRows(table, "id", code);
|
||||||
removeAllRow(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpTypCod", code);
|
removeAllRows(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpTypCod", code);
|
||||||
}
|
}
|
||||||
for (Model model : newModels) {
|
for (Model model : newModels) {
|
||||||
insertEntity(table, model);
|
insertEntity(table, model);
|
||||||
|
@ -1081,9 +1082,9 @@ public class DataBaseHelper {
|
||||||
if (table.compareTo(Constants.DB_TABLE_GROUPS) == 0) {
|
if (table.compareTo(Constants.DB_TABLE_GROUPS) == 0) {
|
||||||
for (Model anObsoleteModel : obsoleteModel) {
|
for (Model anObsoleteModel : obsoleteModel) {
|
||||||
long code = anObsoleteModel.getId();
|
long code = anObsoleteModel.getId();
|
||||||
removeAllRow(table, "id", code);
|
removeAllRows(table, "id", code);
|
||||||
removeAllRow(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", code);
|
removeAllRows(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", code);
|
||||||
removeAllRow(Constants.DB_TABLE_GROUPS_COURSES, "grpCod", code);
|
removeAllRows(Constants.DB_TABLE_GROUPS_COURSES, "grpCod", code);
|
||||||
}
|
}
|
||||||
for (Model model : newModels) {
|
for (Model model : newModels) {
|
||||||
insertGroup((Group) model, courseCode[0]);
|
insertGroup((Group) model, courseCode[0]);
|
||||||
|
@ -1209,6 +1210,20 @@ public class DataBaseHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates all notifications in database
|
||||||
|
*
|
||||||
|
* @param field Field to be updated
|
||||||
|
* @param value New field value
|
||||||
|
*/
|
||||||
|
public void updateAllNotifications(String field, String value) {
|
||||||
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS);
|
||||||
|
for(Entity ent : rows) {
|
||||||
|
ent.setValue(field, value);
|
||||||
|
ent.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a notification in database
|
* Updates a notification in database
|
||||||
*
|
*
|
||||||
|
@ -1217,7 +1232,7 @@ public class DataBaseHelper {
|
||||||
* @param value New field value
|
* @param value New field value
|
||||||
*/
|
*/
|
||||||
public void updateNotification(long id, String field, String value) {
|
public void updateNotification(long id, String field, String value) {
|
||||||
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + id);
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + id);
|
||||||
for(Entity ent : rows) {
|
for(Entity ent : rows) {
|
||||||
ent.setValue(field, value);
|
ent.setValue(field, value);
|
||||||
ent.save();
|
ent.save();
|
||||||
|
@ -1231,8 +1246,9 @@ public class DataBaseHelper {
|
||||||
* @param actual Updated notification
|
* @param actual Updated notification
|
||||||
*/
|
*/
|
||||||
public void updateNotification(long id, SWADNotification actual) {
|
public void updateNotification(long id, SWADNotification actual) {
|
||||||
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + id);
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + id);
|
||||||
long newID = actual.getId();
|
long notifCode = actual.getId();
|
||||||
|
long eventCode = actual.getEventCode();
|
||||||
String eventType = crypto.encrypt(actual.getEventType());
|
String eventType = crypto.encrypt(actual.getEventType());
|
||||||
String eventTime = String.valueOf(actual.getEventTime());
|
String eventTime = String.valueOf(actual.getEventTime());
|
||||||
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
|
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
|
||||||
|
@ -1247,7 +1263,8 @@ public class DataBaseHelper {
|
||||||
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
|
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
|
||||||
|
|
||||||
for(Entity ent : rows) {
|
for(Entity ent : rows) {
|
||||||
ent.setValue("id", newID);
|
ent.setValue("notifCode", notifCode);
|
||||||
|
ent.setValue("eventCode", eventCode);
|
||||||
ent.setValue("eventType", eventType);
|
ent.setValue("eventType", eventType);
|
||||||
ent.setValue("eventTime", eventTime);
|
ent.setValue("eventTime", eventTime);
|
||||||
ent.setValue("userSurname1", userSurname1);
|
ent.setValue("userSurname1", userSurname1);
|
||||||
|
@ -1271,8 +1288,9 @@ public class DataBaseHelper {
|
||||||
* @param actual Updated notification
|
* @param actual Updated notification
|
||||||
*/
|
*/
|
||||||
public void updateNotification(SWADNotification prev, SWADNotification actual) {
|
public void updateNotification(SWADNotification prev, SWADNotification actual) {
|
||||||
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "id = " + prev.getId());
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_NOTIFICATIONS, "notifCode = " + prev.getId());
|
||||||
long newID = actual.getId();
|
long notifCode = actual.getId();
|
||||||
|
long eventCode = actual.getEventCode();
|
||||||
String eventType = crypto.encrypt(actual.getEventType());
|
String eventType = crypto.encrypt(actual.getEventType());
|
||||||
String eventTime = String.valueOf(actual.getEventTime());
|
String eventTime = String.valueOf(actual.getEventTime());
|
||||||
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
|
String userSurname1 = crypto.encrypt(actual.getUserSurname1());
|
||||||
|
@ -1287,7 +1305,8 @@ public class DataBaseHelper {
|
||||||
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
|
String seenRemote = Utils.parseBoolString(actual.isSeenRemote());
|
||||||
|
|
||||||
for(Entity ent : rows) {
|
for(Entity ent : rows) {
|
||||||
ent.setValue("id", newID);
|
ent.setValue("notifCode", notifCode);
|
||||||
|
ent.setValue("eventCode", eventCode);
|
||||||
ent.setValue("eventType", eventType);
|
ent.setValue("eventType", eventType);
|
||||||
ent.setValue("eventTime", eventTime);
|
ent.setValue("eventTime", eventTime);
|
||||||
ent.setValue("userSurname1", userSurname1);
|
ent.setValue("userSurname1", userSurname1);
|
||||||
|
@ -1497,7 +1516,6 @@ public class DataBaseHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private <T> boolean updateRelationship(Pair<String, String> tables, Pair<String, String> idsTables, String relationTable, Pair<String, T> remainField, Pair<String, T> changedField) {
|
private <T> boolean updateRelationship(Pair<String, String> tables, Pair<String, String> idsTables, String relationTable, Pair<String, T> remainField, Pair<String, T> changedField) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -1524,7 +1542,6 @@ public class DataBaseHelper {
|
||||||
/**
|
/**
|
||||||
* Updates an existing group type
|
* Updates an existing group type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private boolean updateGroupType(GroupType prv, GroupType current) {
|
private boolean updateGroupType(GroupType prv, GroupType current) {
|
||||||
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_GROUP_TYPES, "id=" + prv.getId());
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_GROUP_TYPES, "id=" + prv.getId());
|
||||||
boolean returnValue = true;
|
boolean returnValue = true;
|
||||||
|
@ -1559,8 +1576,8 @@ public class DataBaseHelper {
|
||||||
removeRow(Constants.DB_TABLE_GROUPS, g.getId());
|
removeRow(Constants.DB_TABLE_GROUPS, g.getId());
|
||||||
|
|
||||||
//Remove also relationships with courses and group types
|
//Remove also relationships with courses and group types
|
||||||
removeAllRow(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", g.getId());
|
removeAllRows(Constants.DB_TABLE_GROUPS_GROUPTYPES, "grpCod", g.getId());
|
||||||
removeAllRow(Constants.DB_TABLE_GROUPS_COURSES, "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 fieldName Name field to search
|
||||||
* @param value Value field of row to be removed
|
* @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<Entity> rows = db.getEntityList(table, fieldName + "= " + value);
|
List<Entity> rows = db.getEntityList(table, fieldName + "= " + value);
|
||||||
for (Entity ent : rows) {
|
for (Entity ent : rows) {
|
||||||
ent.delete();
|
ent.delete();
|
||||||
|
@ -1592,7 +1609,7 @@ public class DataBaseHelper {
|
||||||
*
|
*
|
||||||
* @param p PairTable to be removed
|
* @param p PairTable to be removed
|
||||||
*/
|
*/
|
||||||
public void removePairTable(@SuppressWarnings("rawtypes") PairTable p) {
|
public void removePairTable(PairTable<?, ?> p) {
|
||||||
String table = p.getTable();
|
String table = p.getTable();
|
||||||
Integer first = (Integer) p.getFirst();
|
Integer first = (Integer) p.getFirst();
|
||||||
Integer second = (Integer) p.getSecond();
|
Integer second = (Integer) p.getSecond();
|
||||||
|
@ -1635,7 +1652,7 @@ public class DataBaseHelper {
|
||||||
* @return Last time the test was updated
|
* @return Last time the test was updated
|
||||||
*/
|
*/
|
||||||
public String getTimeOfLastTestUpdate(long selectedCourseCode) {
|
public String getTimeOfLastTestUpdate(long selectedCourseCode) {
|
||||||
String where = "id=" + selectedCourseCode;
|
String where = "notifCode=" + selectedCourseCode;
|
||||||
String orderby = null;
|
String orderby = null;
|
||||||
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_TEST_CONFIG, where, orderby);
|
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_TEST_CONFIG, where, orderby);
|
||||||
String f = "0";
|
String f = "0";
|
||||||
|
@ -1864,10 +1881,6 @@ public class DataBaseHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void markNotificationAsSeenLocally(String notificationCode) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty table from database
|
* Empty table from database
|
||||||
*
|
*
|
||||||
|
@ -1897,23 +1910,7 @@ public class DataBaseHelper {
|
||||||
* Clean data of all tables from database. Removes users photos from external storage
|
* Clean data of all tables from database. Removes users photos from external storage
|
||||||
*/
|
*/
|
||||||
public void cleanTables() {
|
public void cleanTables() {
|
||||||
emptyTable(Constants.DB_TABLE_NOTIFICATIONS);
|
db.emptyTables();
|
||||||
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);
|
|
||||||
compactDB();
|
compactDB();
|
||||||
|
|
||||||
// Removes users photos from external storage (Android 2.2 or higher only)
|
// Removes users photos from external storage (Android 2.2 or higher only)
|
||||||
|
@ -1969,11 +1966,6 @@ public class DataBaseHelper {
|
||||||
*/
|
*/
|
||||||
public void upgradeDB(Context context) {
|
public void upgradeDB(Context context) {
|
||||||
int dbVersion = db.getDB().getVersion();
|
int dbVersion = db.getDB().getVersion();
|
||||||
boolean found = false;
|
|
||||||
int i = 0;
|
|
||||||
int rowsAffected;
|
|
||||||
ContentValues fields;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modify database keeping data:
|
* Modify database keeping data:
|
||||||
* 1. Create temporary table __DB_TABLE_GROUPS (with the new model)
|
* 1. Create temporary table __DB_TABLE_GROUPS (with the new model)
|
||||||
|
@ -1987,56 +1979,16 @@ public class DataBaseHelper {
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
/* version 15-16
|
||||||
/* 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
|
|
||||||
* changes on notifications table:
|
* changes on notifications table:
|
||||||
* - new field seenLocal initialized to true
|
* - new field notifCode
|
||||||
* - new field seenRemote initialized to true
|
* - changed field id to eventCode
|
||||||
* */
|
* */
|
||||||
} else if (dbVersion < 15) {
|
if (dbVersion == 16) {
|
||||||
fields = new ContentValues();
|
//without keeping data
|
||||||
fields.put("seenLocal", Utils.parseBoolString(true));
|
db.getDB().execSQL("DROP TABLE " + Constants.DB_TABLE_NOTIFICATIONS + ";");
|
||||||
fields.put("seenRemote", Utils.parseBoolString(true));
|
db.getDB().execSQL("CREATE TABLE " + Constants.DB_TABLE_NOTIFICATIONS + " (_id integer primary key autoincrement, notifCode long, eventCode long, eventType text, eventTime text,"
|
||||||
rowsAffected = db.getDB().update(Constants.DB_TABLE_NOTIFICATIONS, fields, null, null);
|
+ " userSurname1 text, userSurname2 text, userFirstname text, userPhoto text, location text, summary text, status text, content text, seenLocal text, seenRemote text); ");
|
||||||
}
|
}
|
||||||
|
|
||||||
compactDB();
|
compactDB();
|
||||||
|
|
|
@ -20,8 +20,6 @@ package es.ugr.swad.swadroid.model;
|
||||||
|
|
||||||
import org.ksoap2.serialization.PropertyInfo;
|
import org.ksoap2.serialization.PropertyInfo;
|
||||||
|
|
||||||
import es.ugr.swad.swadroid.utils.Utils;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +28,10 @@ import java.util.Hashtable;
|
||||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com> *
|
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com> *
|
||||||
*/
|
*/
|
||||||
public class SWADNotification extends Model {
|
public class SWADNotification extends Model {
|
||||||
|
/**
|
||||||
|
* Event id (not unique)
|
||||||
|
*/
|
||||||
|
private long eventCode;
|
||||||
/**
|
/**
|
||||||
* Notification type
|
* Notification type
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +81,7 @@ public class SWADNotification extends Model {
|
||||||
*/
|
*/
|
||||||
private boolean seenRemote;
|
private boolean seenRemote;
|
||||||
private static final PropertyInfo PI_id = new PropertyInfo();
|
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_eventType = new PropertyInfo();
|
||||||
private static final PropertyInfo PI_eventTime = new PropertyInfo();
|
private static final PropertyInfo PI_eventTime = new PropertyInfo();
|
||||||
private static final PropertyInfo PI_userSurname1 = 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 =
|
private static PropertyInfo[] PI_PROP_ARRAY =
|
||||||
{
|
{
|
||||||
PI_id,
|
PI_id,
|
||||||
|
PI_eventCode,
|
||||||
PI_eventType,
|
PI_eventType,
|
||||||
PI_eventTime,
|
PI_eventTime,
|
||||||
PI_userSurname1,
|
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 eventType Notification type
|
||||||
* @param eventTime Notification timestamp
|
* @param eventTime Notification timestamp
|
||||||
* @param userSurname1 Sender first surname
|
* @param userSurname1 Sender first surname
|
||||||
|
@ -119,12 +124,13 @@ public class SWADNotification extends Model {
|
||||||
* @param seenLocal Notification has been seen locally
|
* @param seenLocal Notification has been seen locally
|
||||||
* @param seenRemote Notification has been seen in SWAD
|
* @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 userSurname1, String userSurname2, String userFirstName,
|
||||||
String userPhoto, String location, String summary, int status,
|
String userPhoto, String location, String summary, int status,
|
||||||
String content, boolean seenLocal, boolean seenRemote) {
|
String content, boolean seenLocal, boolean seenRemote) {
|
||||||
|
|
||||||
super(id);
|
super(id);
|
||||||
|
this.eventCode = eventCode;
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
this.eventTime = eventTime;
|
this.eventTime = eventTime;
|
||||||
this.userSurname1 = userSurname1;
|
this.userSurname1 = userSurname1;
|
||||||
|
@ -139,6 +145,24 @@ public class SWADNotification extends Model {
|
||||||
this.seenRemote = seenRemote;
|
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
|
* Gets notification type
|
||||||
*
|
*
|
||||||
|
@ -364,13 +388,14 @@ public class SWADNotification extends Model {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SWADNotification [eventType=" + eventType + ", eventTime="
|
return "SWADNotification [notifCode=" + getId() + ", eventCode=" + eventCode + ", eventType="
|
||||||
+ eventTime + ", userSurname1=" + userSurname1
|
+ eventType + ", eventTime=" + eventTime + ", userSurname1="
|
||||||
+ ", userSurname2=" + userSurname2 + ", userFirstName="
|
+ userSurname1 + ", userSurname2=" + userSurname2
|
||||||
+ userFirstName + ", userPhoto=" + userPhoto + ", location="
|
+ ", userFirstName=" + userFirstName + ", userPhoto="
|
||||||
+ location + ", summary=" + summary + ", status=" + status
|
+ userPhoto + ", location=" + location + ", summary=" + summary
|
||||||
+ ", content=" + content + ", seenLocal=" + seenLocal
|
+ ", status=" + status + ", content=" + content
|
||||||
+ ", seenRemote=" + seenRemote + "]";
|
+ ", seenLocal=" + seenLocal + ", seenRemote=" + seenRemote
|
||||||
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -381,11 +406,14 @@ public class SWADNotification extends Model {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((content == null) ? 0 : content.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 + (int) (eventTime ^ (eventTime >>> 32));
|
||||||
result = prime * result
|
result = prime * result
|
||||||
+ ((eventType == null) ? 0 : eventType.hashCode());
|
+ ((eventType == null) ? 0 : eventType.hashCode());
|
||||||
result = prime * result
|
result = prime * result
|
||||||
+ ((location == null) ? 0 : location.hashCode());
|
+ ((location == null) ? 0 : location.hashCode());
|
||||||
|
result = prime * result + (seenLocal ? 1231 : 1237);
|
||||||
|
result = prime * result + (seenRemote ? 1231 : 1237);
|
||||||
result = prime * result + status;
|
result = prime * result + status;
|
||||||
result = prime * result + ((summary == null) ? 0 : summary.hashCode());
|
result = prime * result + ((summary == null) ? 0 : summary.hashCode());
|
||||||
result = prime * result
|
result = prime * result
|
||||||
|
@ -416,6 +444,8 @@ public class SWADNotification extends Model {
|
||||||
return false;
|
return false;
|
||||||
} else if (!content.equals(other.content))
|
} else if (!content.equals(other.content))
|
||||||
return false;
|
return false;
|
||||||
|
if (eventCode != other.eventCode)
|
||||||
|
return false;
|
||||||
if (eventTime != other.eventTime)
|
if (eventTime != other.eventTime)
|
||||||
return false;
|
return false;
|
||||||
if (eventType == null) {
|
if (eventType == null) {
|
||||||
|
@ -428,6 +458,10 @@ public class SWADNotification extends Model {
|
||||||
return false;
|
return false;
|
||||||
} else if (!location.equals(other.location))
|
} else if (!location.equals(other.location))
|
||||||
return false;
|
return false;
|
||||||
|
if (seenLocal != other.seenLocal)
|
||||||
|
return false;
|
||||||
|
if (seenRemote != other.seenRemote)
|
||||||
|
return false;
|
||||||
if (status != other.status)
|
if (status != other.status)
|
||||||
return false;
|
return false;
|
||||||
if (summary == null) {
|
if (summary == null) {
|
||||||
|
@ -468,33 +502,36 @@ public class SWADNotification extends Model {
|
||||||
object = this.getId();
|
object = this.getId();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
object = eventType;
|
object = eventCode;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
object = eventTime;
|
object = eventType;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
object = userSurname1;
|
object = eventTime;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
object = userSurname2;
|
object = userSurname1;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
object = userFirstName;
|
object = userSurname2;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
object = userPhoto;
|
object = userFirstName;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
object = location;
|
object = userPhoto;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
object = summary;
|
object = location;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
object = status;
|
object = summary;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
object = status;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
object = content;
|
object = content;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +543,7 @@ public class SWADNotification extends Model {
|
||||||
* @see org.ksoap2.serialization.KvmSerializable#getPropertyCount()
|
* @see org.ksoap2.serialization.KvmSerializable#getPropertyCount()
|
||||||
*/
|
*/
|
||||||
public int getPropertyCount() {
|
public int getPropertyCount() {
|
||||||
return 9;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -519,42 +556,46 @@ public class SWADNotification extends Model {
|
||||||
propertyInfo.name = "id";
|
propertyInfo.name = "id";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
propertyInfo.type = PropertyInfo.LONG_CLASS;
|
||||||
|
propertyInfo.name = "eventCode";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "eventType";
|
propertyInfo.name = "eventType";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 3:
|
||||||
propertyInfo.type = PropertyInfo.LONG_CLASS;
|
propertyInfo.type = PropertyInfo.LONG_CLASS;
|
||||||
propertyInfo.name = "eventTime";
|
propertyInfo.name = "eventTime";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 4:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "userSurname1";
|
propertyInfo.name = "userSurname1";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 5:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "userSurname2";
|
propertyInfo.name = "userSurname2";
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 6:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "userFirstName";
|
propertyInfo.name = "userFirstName";
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 7:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "userPhoto";
|
propertyInfo.name = "userPhoto";
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "location";
|
propertyInfo.name = "location";
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 9:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "summary";
|
propertyInfo.name = "summary";
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 10:
|
||||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||||
propertyInfo.name = "status";
|
propertyInfo.name = "status";
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 11:
|
||||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||||
propertyInfo.name = "content";
|
propertyInfo.name = "content";
|
||||||
break;
|
break;
|
||||||
|
@ -570,33 +611,36 @@ public class SWADNotification extends Model {
|
||||||
this.setId((Long) obj);
|
this.setId((Long) obj);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
eventType = (String) obj;
|
eventCode = (Long) obj;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
eventTime = (Long) obj;
|
eventType = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
userSurname1 = (String) obj;
|
eventTime = (Long) obj;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
userSurname2 = (String) obj;
|
userSurname1 = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
userFirstName = (String) obj;
|
userSurname2 = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
userPhoto = (String) obj;
|
userFirstName = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
location = (String) obj;
|
userPhoto = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
summary = (String) obj;
|
location = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
status = (Integer) obj;
|
summary = (String) obj;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
status = (Integer) obj;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
content = (String) obj;
|
content = (String) obj;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Messages extends Module {
|
||||||
/**
|
/**
|
||||||
* Message code
|
* Message code
|
||||||
*/
|
*/
|
||||||
private Long notificationCode;
|
private Long eventCode;
|
||||||
/**
|
/**
|
||||||
* Message's receivers
|
* Message's receivers
|
||||||
*/
|
*/
|
||||||
|
@ -136,7 +136,7 @@ public class Messages extends Module {
|
||||||
|
|
||||||
b.setOnClickListener(positiveClickListener);
|
b.setOnClickListener(positiveClickListener);
|
||||||
|
|
||||||
if (notificationCode != 0) {
|
if (eventCode != 0) {
|
||||||
subject = getIntent().getStringExtra("summary");
|
subject = getIntent().getStringExtra("summary");
|
||||||
|
|
||||||
subjectText.setText("Re: " + subject);
|
subjectText.setText("Re: " + subject);
|
||||||
|
@ -161,7 +161,7 @@ public class Messages extends Module {
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
notificationCode = getIntent().getLongExtra("notificationCode", 0);
|
eventCode = getIntent().getLongExtra("eventCode", 0);
|
||||||
|
|
||||||
messageDialog = DialogFactory.createPositiveNegativeDialog(this,
|
messageDialog = DialogFactory.createPositiveNegativeDialog(this,
|
||||||
R.layout.dialog_messages,
|
R.layout.dialog_messages,
|
||||||
|
@ -238,7 +238,7 @@ public class Messages extends Module {
|
||||||
|
|
||||||
createRequest();
|
createRequest();
|
||||||
addParam("wsKey", Constants.getLoggedUser().getWsKey());
|
addParam("wsKey", Constants.getLoggedUser().getWsKey());
|
||||||
addParam("messageCode", notificationCode.intValue());
|
addParam("messageCode", eventCode.intValue());
|
||||||
addParam("to", receivers);
|
addParam("to", receivers);
|
||||||
addParam("subject", subject);
|
addParam("subject", subject);
|
||||||
addParam("body", body);
|
addParam("body", body);
|
||||||
|
@ -310,7 +310,7 @@ public class Messages extends Module {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
notificationCode = savedInstanceState.getLong("notificationCode");
|
eventCode = savedInstanceState.getLong("eventCode");
|
||||||
receivers = savedInstanceState.getString("receivers");
|
receivers = savedInstanceState.getString("receivers");
|
||||||
receiversNames = savedInstanceState.getString("receiversNames");
|
receiversNames = savedInstanceState.getString("receiversNames");
|
||||||
subject = savedInstanceState.getString("subject");
|
subject = savedInstanceState.getString("subject");
|
||||||
|
@ -328,7 +328,7 @@ public class Messages extends Module {
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
readData();
|
readData();
|
||||||
|
|
||||||
outState.putLong("notificationCode", notificationCode);
|
outState.putLong("eventCode", eventCode);
|
||||||
outState.putString("receivers", receivers);
|
outState.putString("receivers", receivers);
|
||||||
outState.putString("receiversNames", receiversNames);
|
outState.putString("receiversNames", receiversNames);
|
||||||
outState.putString("subject", subject);
|
outState.putString("subject", subject);
|
||||||
|
|
|
@ -40,7 +40,8 @@ import es.ugr.swad.swadroid.utils.Utils;
|
||||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class NotificationItem extends MenuActivity {
|
public class NotificationItem extends MenuActivity {
|
||||||
private Long notificationCode;
|
private Long notifCode;
|
||||||
|
private Long eventCode;
|
||||||
private String sender;
|
private String sender;
|
||||||
private String userPhoto;
|
private String userPhoto;
|
||||||
private String course;
|
private String course;
|
||||||
|
@ -85,7 +86,8 @@ public class NotificationItem extends MenuActivity {
|
||||||
replyButton.setVisibility(View.GONE);
|
replyButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//notificationCode =
|
notifCode = Long.valueOf(this.getIntent().getStringExtra("notifCode"));
|
||||||
|
eventCode = Long.valueOf(this.getIntent().getStringExtra("eventCode"));
|
||||||
sender = this.getIntent().getStringExtra("sender");
|
sender = this.getIntent().getStringExtra("sender");
|
||||||
userPhoto = this.getIntent().getStringExtra("userPhoto");
|
userPhoto = this.getIntent().getStringExtra("userPhoto");
|
||||||
course = this.getIntent().getStringExtra("course");
|
course = this.getIntent().getStringExtra("course");
|
||||||
|
@ -119,8 +121,7 @@ public class NotificationItem extends MenuActivity {
|
||||||
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
|
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
|
||||||
|
|
||||||
//Set notification as seen locally
|
//Set notification as seen locally
|
||||||
notificationCode = Long.valueOf(this.getIntent().getStringExtra("notificationCode"));
|
dbHelper.updateNotification(notifCode, "seenLocal", Utils.parseBoolString(true));
|
||||||
dbHelper.updateNotification(notificationCode, "seenLocal", Utils.parseBoolString(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,9 +130,8 @@ public class NotificationItem extends MenuActivity {
|
||||||
* @param v Actual view
|
* @param v Actual view
|
||||||
*/
|
*/
|
||||||
public void onReplyMessageClick(View v) {
|
public void onReplyMessageClick(View v) {
|
||||||
notificationCode = Long.valueOf(this.getIntent().getStringExtra("notificationCode"));
|
|
||||||
Intent activity = new Intent(this, Messages.class);
|
Intent activity = new Intent(this, Messages.class);
|
||||||
activity.putExtra("notificationCode", notificationCode);
|
activity.putExtra("eventCode", eventCode);
|
||||||
activity.putExtra("summary", summary);
|
activity.putExtra("summary", summary);
|
||||||
startActivity(activity);
|
startActivity(activity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import es.ugr.swad.swadroid.R;
|
||||||
import es.ugr.swad.swadroid.gui.AlertNotification;
|
import es.ugr.swad.swadroid.gui.AlertNotification;
|
||||||
import es.ugr.swad.swadroid.model.SWADNotification;
|
import es.ugr.swad.swadroid.model.SWADNotification;
|
||||||
import es.ugr.swad.swadroid.modules.Module;
|
import es.ugr.swad.swadroid.modules.Module;
|
||||||
|
import es.ugr.swad.swadroid.utils.Utils;
|
||||||
|
|
||||||
import org.ksoap2.serialization.SoapObject;
|
import org.ksoap2.serialization.SoapObject;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
@ -112,6 +113,7 @@ public class Notifications extends Module {
|
||||||
private OnItemClickListener clickListener = new OnItemClickListener() {
|
private OnItemClickListener clickListener = new OnItemClickListener() {
|
||||||
public void onItemClick(AdapterView<?> av, View v, int position, long rowId) {
|
public void onItemClick(AdapterView<?> av, View v, int position, long rowId) {
|
||||||
//adapter.toggleContentVisibility(position);
|
//adapter.toggleContentVisibility(position);
|
||||||
|
TextView id = (TextView) v.findViewById(R.id.notifCode);
|
||||||
TextView code = (TextView) v.findViewById(R.id.eventCode);
|
TextView code = (TextView) v.findViewById(R.id.eventCode);
|
||||||
TextView type = (TextView) v.findViewById(R.id.eventType);
|
TextView type = (TextView) v.findViewById(R.id.eventType);
|
||||||
TextView userPhoto = (TextView) v.findViewById(R.id.eventUserPhoto);
|
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);
|
TextView time = (TextView) v.findViewById(R.id.eventTime);
|
||||||
|
|
||||||
Intent activity = new Intent(getApplicationContext(), NotificationItem.class);
|
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("notificationType", type.getText().toString());
|
||||||
activity.putExtra("userPhoto", userPhoto.getText().toString());
|
activity.putExtra("userPhoto", userPhoto.getText().toString());
|
||||||
activity.putExtra("sender", sender.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.courseSelectedText).setVisibility(View.GONE);
|
||||||
this.findViewById(R.id.groupSpinner).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 = (ImageView) this.findViewById(R.id.moduleIcon);
|
||||||
image.setBackgroundResource(R.drawable.bell);
|
image.setBackgroundResource(R.drawable.bell);
|
||||||
|
@ -246,6 +250,16 @@ public class Notifications extends Module {
|
||||||
onError();
|
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)
|
/* (non-Javadoc)
|
||||||
* @see es.ugr.swad.swadroid.modules.Module#onResume()
|
* @see es.ugr.swad.swadroid.modules.Module#onResume()
|
||||||
*/
|
*/
|
||||||
|
@ -299,7 +313,8 @@ public class Notifications extends Module {
|
||||||
notifCount = soap.getPropertyCount();
|
notifCount = soap.getPropertyCount();
|
||||||
for (int i = 0; i < notifCount; i++) {
|
for (int i = 0; i < notifCount; i++) {
|
||||||
SoapObject pii = (SoapObject) soap.getProperty(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();
|
String eventType = pii.getProperty("eventType").toString();
|
||||||
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
|
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
|
||||||
String userSurname1 = pii.getProperty("userSurname1").toString();
|
String userSurname1 = pii.getProperty("userSurname1").toString();
|
||||||
|
@ -312,7 +327,7 @@ public class Notifications extends Module {
|
||||||
String content = pii.getProperty("content").toString();
|
String content = pii.getProperty("content").toString();
|
||||||
|
|
||||||
//TODO Add "notification seen" info from SWAD
|
//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);
|
dbHelper.insertNotification(n);
|
||||||
|
|
||||||
if(isDebuggable)
|
if(isDebuggable)
|
||||||
|
|
|
@ -99,7 +99,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
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"));
|
final String userPhoto = cursor.getString(cursor.getColumnIndex("userPhoto"));
|
||||||
long unixTime;
|
long unixTime;
|
||||||
String type = "";
|
String type = "";
|
||||||
|
@ -123,7 +124,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setScrollContainer(false);
|
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 eventUserPhoto = (TextView) view.findViewById(R.id.eventUserPhoto);
|
||||||
TextView eventType = (TextView) view.findViewById(R.id.eventType);
|
TextView eventType = (TextView) view.findViewById(R.id.eventType);
|
||||||
TextView eventDate = (TextView) view.findViewById(R.id.eventDate);
|
TextView eventDate = (TextView) view.findViewById(R.id.eventDate);
|
||||||
|
@ -146,7 +148,8 @@ public class NotificationsCursorAdapter extends CursorAdapter {
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
if (eventType != null) {
|
if (eventType != null) {
|
||||||
eventCode.setText(notificationCode.toString());
|
notifCodeHided.setText(notifCode.toString());
|
||||||
|
eventCodeHided.setText(eventCode.toString());
|
||||||
eventUserPhoto.setText(crypto.decrypt(userPhoto));
|
eventUserPhoto.setText(crypto.decrypt(userPhoto));
|
||||||
type = crypto.decrypt(cursor.getString(cursor.getColumnIndex("eventType")));
|
type = crypto.decrypt(cursor.getString(cursor.getColumnIndex("eventType")));
|
||||||
//messageReplyButton.setVisibility(View.GONE);
|
//messageReplyButton.setVisibility(View.GONE);
|
||||||
|
|
|
@ -340,7 +340,8 @@ public class NotificationsSyncAdapterService extends Service {
|
||||||
notifCount = soap.getPropertyCount();
|
notifCount = soap.getPropertyCount();
|
||||||
for (int i = 0; i < notifCount; i++) {
|
for (int i = 0; i < notifCount; i++) {
|
||||||
SoapObject pii = (SoapObject) soap.getProperty(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();
|
String eventType = pii.getProperty("eventType").toString();
|
||||||
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
|
Long eventTime = Long.valueOf(pii.getProperty("eventTime").toString());
|
||||||
String userSurname1 = pii.getProperty("userSurname1").toString();
|
String userSurname1 = pii.getProperty("userSurname1").toString();
|
||||||
|
@ -353,7 +354,7 @@ public class NotificationsSyncAdapterService extends Service {
|
||||||
String content = pii.getProperty("content").toString();
|
String content = pii.getProperty("content").toString();
|
||||||
|
|
||||||
//TODO Add "notification seen" info from SWAD
|
//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);
|
dbHelper.insertNotification(n);
|
||||||
|
|
||||||
//Log.d(TAG, n.toString());
|
//Log.d(TAG, n.toString());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user