Merge branch 'develop' of github.com:Amab/SWADroid into develop

git-svn-id: https://forja.rediris.es/svn/cusl6-swadroid/trunk@236 5bc14d19-1e4b-4ba2-aa50-860af135f48c
This commit is contained in:
Juan Miguel Boyero Corral 2012-02-01 23:45:01 +00:00
commit 60b1532730
12 changed files with 88 additions and 18 deletions

1
.gitignore vendored
View File

@ -7,4 +7,3 @@ capturas/
iconos/
gitstats/
SWADroidTest/
SWADroid.apk

View File

@ -1,3 +1,12 @@
## 0.7.1 (2012-01-11)
* Fixed rendering errors in marks function
* Improved rendering speed in marks function
## 0.7 (2012-01-10)
* Added marks function in notifications module
## 0.6.2 (2011-12-09)
* Added Blog URL to preferences screen

BIN
SWADroid.apk Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.ugr.swad.swadroid"
android:installLocation="auto" android:versionName="0.6.2" android:versionCode="28">
android:installLocation="auto" android:versionName="0.7.1" android:versionCode="31">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher_swadroid" android:debuggable="true">
<activity android:name=".SWADMain"
android:label="@string/app_name"
@ -31,6 +31,6 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"></uses-sdk>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"></uses-sdk>
<supports-screens android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:anyDensity="true" android:largeScreens="true" android:xlargeScreens="true"></supports-screens>
</manifest>

View File

@ -210,6 +210,8 @@ public final class R {
public static final int noQuestionsPluggableTestsDownloadMsg=0x7f070045;
public static final int noSubjectMsg=0x7f070039;
public static final int notice=0x7f07002e;
public static final int notificationsAlertMsg=0x7f070073;
public static final int notificationsAlertTitle=0x7f070072;
public static final int notificationsDownloadedMsg=0x7f070023;
public static final int notificationsEmptyListMsg=0x7f070022;
public static final int notificationsModuleLabel=0x7f070002;

View File

@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-14
target=android-15

View File

@ -117,4 +117,6 @@
plataforma de teleformación SWAD.\nObtenlo gratis aquí:
https://market.android.com/details?id=es.ugr.swad.swadroid</string>
<string name="twitterTitle">Twitter</string><string name="facebookTitle">Facebook</string><string name="googlePlusTitle">Google+</string><string name="mailingListTitle">Lista de correo</string><string name="blogTitle">Blog</string><string name="marketTitle">Android Market</string>
<string name="notificationsAlertTitle">Nuevas notificaciones</string>
<string name="notificationsAlertMsg">nuevas notificaciones</string>
</resources>

View File

@ -123,7 +123,7 @@
<string name="facebookTitle">Facebook</string>
<string name="googlePlusTitle">Google+</string>
<string name="mailingListTitle">Mailing list</string>
<string name="blogTitle">Blog</string><string name="marketTitle">Android Market</string>
<string name="blogTitle">Blog</string><string name="marketTitle">Android Market</string><string name="notificationsAlertTitle">New notifications</string><string name="notificationsAlertMsg">new notifications</string>
</resources>

View File

@ -122,7 +122,7 @@ public class DataBaseHelper {
ent.getInt(params.getFirst()),
ent.getInt(params.getSecond()));
} else if(table.equals(Global.DB_TABLE_NOTIFICATIONS)) {
o = new Notification(ent.getInt("id"),
o = new SWADNotification(ent.getInt("id"),
ent.getString("eventType"),
ent.getLong("eventTime"),
ent.getString("userSurname1"),
@ -272,7 +272,7 @@ public class DataBaseHelper {
* Inserts a notification in database
* @param n Notification to be inserted
*/
public void insertNotification(Notification n)
public void insertNotification(SWADNotification n)
{
Entity ent = new Entity(Global.DB_TABLE_NOTIFICATIONS);
@ -413,7 +413,7 @@ public class DataBaseHelper {
* @param prev Notification to be updated
* @param actual Updated notification
*/
public void updateNotification(Notification prev, Notification actual)
public void updateNotification(SWADNotification prev, SWADNotification actual)
{
List<Entity> rows = db.getEntityList(Global.DB_TABLE_NOTIFICATIONS, "id = " + prev.getId());
Entity ent = rows.get(0);

View File

@ -26,7 +26,7 @@ import org.ksoap2.serialization.PropertyInfo;
* Class for store a notification
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com> *
*/
public class Notification extends Model {
public class SWADNotification extends Model {
/**
* Notification type
*/
@ -99,7 +99,7 @@ public class Notification extends Model {
* @param summary Notification summary
* @param status Notification summary
*/
public Notification(long id, String eventType, long eventTime,
public SWADNotification(long id, String eventType, long eventTime,
String userSurname1, String userSurname2, String userFirstName,
String location, String summary, int status, String content) {

View File

@ -20,6 +20,8 @@ package es.ugr.swad.swadroid.modules.notifications;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
/**
@ -35,6 +37,8 @@ public class Marks extends Activity {
setContentView(webview);
String content = this.getIntent().getStringExtra("content");
webview.loadData(content, "text/html", null);
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.loadDataWithBaseURL("", content, "text/html", "utf-8", "");
}
}

View File

@ -32,9 +32,13 @@ import es.ugr.swad.swadroid.Global;
import es.ugr.swad.swadroid.R;
import es.ugr.swad.swadroid.model.DataBaseHelper;
import es.ugr.swad.swadroid.model.User;
import es.ugr.swad.swadroid.model.Notification;
import es.ugr.swad.swadroid.model.SWADNotification;
import es.ugr.swad.swadroid.modules.Module;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
@ -73,6 +77,14 @@ public class Notifications extends Module {
* Cursor orderby parameter
*/
private String orderby = "eventTime DESC";
/**
* Notifications counter
*/
private int notifCount;
/**
* Unique identifier for notification alerts
*/
private int NOTIF_ALERT_ID = 1982;
/**
* Notifications tag name for Logcat
*/
@ -173,7 +185,7 @@ public class Notifications extends Module {
protected void requestService() throws NoSuchAlgorithmException,
IOException, XmlPullParserException, SoapFault,
IllegalAccessException, InstantiationException {
//Calculates next timestamp to be requested
Long timestamp = new Long(dbHelper.getFieldOfLastNotification("eventTime"));
timestamp++;
@ -182,7 +194,7 @@ public class Notifications extends Module {
createRequest();
addParam("wsKey", User.getWsKey());
addParam("beginTime", timestamp);
sendRequest(Notification.class, false);
sendRequest(SWADNotification.class, false);
if (result != null) {
dbHelper.beginTransaction();
@ -190,8 +202,8 @@ public class Notifications extends Module {
//Stores notifications data returned by webservice response
Vector<?> res = (Vector<?>) result;
SoapObject soap = (SoapObject) res.get(1);
int csSize = soap.getPropertyCount();
for (int i = 0; i < csSize; i++) {
notifCount = soap.getPropertyCount();
for (int i = 0; i < notifCount; i++) {
SoapObject pii = (SoapObject)soap.getProperty(i);
Long notificationCode = new Long(pii.getProperty("notificationCode").toString());
String eventType = pii.getProperty("eventType").toString();
@ -203,7 +215,7 @@ public class Notifications extends Module {
String summary = pii.getProperty("summary").toString();
Integer status = new Integer(pii.getProperty("status").toString());
String content = pii.getProperty("content").toString();
Notification n = new Notification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, location, summary, status, content);
SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, location, summary, status, content);
dbHelper.insertNotification(n);
if(isDebuggable)
@ -211,7 +223,7 @@ public class Notifications extends Module {
}
//Request finalized without errors
Log.i(TAG, "Retrieved " + csSize + " notifications");
Log.i(TAG, "Retrieved " + notifCount + " notifications");
//Clear old notifications to control database size
dbHelper.clearOldNotifications(SIZE_LIMIT);
@ -219,6 +231,46 @@ public class Notifications extends Module {
dbHelper.endTransaction();
}
}
protected void alertNotif() {
if(notifCount > 0) {
//Obtain a reference to the notification service
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notManager =
(NotificationManager) getSystemService(ns);
//Configure the alert
int icon = R.drawable.ic_launcher_swadroid;
long hour = System.currentTimeMillis();
Notification notif =
new Notification(icon, getString(R.string.notificationsAlertTitle), hour);
//Configure the Intent
Context context = getApplicationContext();
Intent notIntent = new Intent(context,
Notifications.class);
PendingIntent contIntent = PendingIntent.getActivity(
context, 0, notIntent, 0);
notif.setLatestEventInfo(
context, getString(R.string.notificationsAlertTitle), notifCount + " " +
getString(R.string.notificationsAlertMsg), contIntent);
//AutoCancel: alert disappears when pushed
notif.flags |= Notification.FLAG_AUTO_CANCEL;
//Add sound, vibration and lights
notif.defaults |= Notification.DEFAULT_SOUND;
//notif.defaults |= Notification.DEFAULT_VIBRATE;
notif.defaults |= Notification.DEFAULT_LIGHTS;
//Send alert
notManager.notify(NOTIF_ALERT_ID, notif);
}
}
/* (non-Javadoc)
* @see es.ugr.swad.swadroid.modules.Module#connect()
@ -238,6 +290,8 @@ public class Notifications extends Module {
protected void postConnect() {
refreshScreen();
Toast.makeText(this, R.string.notificationsDownloadedMsg, Toast.LENGTH_SHORT).show();
alertNotif();
}
/**