From bb02d6dad23e05d9d62f78001e194afa48c58cbd Mon Sep 17 00:00:00 2001 From: Helena Rodriguez Date: Fri, 14 Dec 2012 21:13:02 +0100 Subject: [PATCH] Modified some messages of download notifications --- SWADroid/res/values-ca/strings.xml | 2 +- SWADroid/res/values-de/strings.xml | 2 +- SWADroid/res/values-es/strings.xml | 2 +- SWADroid/res/values/strings.xml | 2 +- .../modules/downloads/DirectoryNavigator.java | 1 - .../downloads/DownloadNotification.java | 12 ++++--- .../downloads/FileDownloaderAsyncTask.java | 32 ++++++++++++++----- 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/SWADroid/res/values-ca/strings.xml b/SWADroid/res/values-ca/strings.xml index ebb73e28..1c1b64d1 100644 --- a/SWADroid/res/values-ca/strings.xml +++ b/SWADroid/res/values-ca/strings.xml @@ -144,6 +144,6 @@ Seleccioneu zona Fitxer: No hi ha connexió. Ho sentim però aquesta funció necessita connexió. - There is not any app that can open this file. Location: + No Es Pot obrir this Arxiu. \ No newline at end of file diff --git a/SWADroid/res/values-de/strings.xml b/SWADroid/res/values-de/strings.xml index 8cf9d1c5..f7cd1b21 100644 --- a/SWADroid/res/values-de/strings.xml +++ b/SWADroid/res/values-de/strings.xml @@ -176,6 +176,6 @@ Wählen Sie Bereich Datei: Es gibt nicht conection.Sorry, aber diese Funktion muss conection. - Es kann diese Datei nicht öffnen. Location: + Es kann diese Datei nicht öffnen. \ No newline at end of file diff --git a/SWADroid/res/values-es/strings.xml b/SWADroid/res/values-es/strings.xml index 4eeede99..ca79a95e 100644 --- a/SWADroid/res/values-es/strings.xml +++ b/SWADroid/res/values-es/strings.xml @@ -269,7 +269,7 @@ Seleccione: Sesiones de prácticas - Nueva Seleccione zona Archivo: No hay conexión. Lo sentimos pero esta función necesita conexión. - No se puede abrir este archivo. Ubicación: + No se puede abrir este archivo. diff --git a/SWADroid/res/values/strings.xml b/SWADroid/res/values/strings.xml index fa7fb934..7efd85b7 100644 --- a/SWADroid/res/values/strings.xml +++ b/SWADroid/res/values/strings.xml @@ -280,5 +280,5 @@ configuration anytime using the "Clean Database" option\n\nDo you want to contin Select zone File: There is not connection. Sorry but this function needs connection. - No Es Pot obrir this Arxiu. ubicació: + No application can open this file diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java index 7582bac1..40bc002d 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java +++ b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DirectoryNavigator.java @@ -31,7 +31,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; -import android.util.Log; /** * Class used to navigate around the XML file. That XML file contains the diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DownloadNotification.java b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DownloadNotification.java index 466c77d3..600c6261 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DownloadNotification.java +++ b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/DownloadNotification.java @@ -129,14 +129,16 @@ public class DownloadNotification { //build up the new status message CharSequence contentText; - if(notificationIntent != null) + if(notificationIntent != null){ contentText = mContext.getString(R.string.clickToOpenFile); - else - contentText = mContext.getString(R.string.noApp) + " " + directoryPath + File.separator+ fileName; + mContentTitle = fileName; //Full title of the notification in the pull down + }else{ + contentText = mContext.getString(R.string.noApp); + mContentTitle = directoryPath + File.separator+ fileName; + } //publish it to the status bar mNotification.setLatestEventInfo(mContext, mContentTitle, contentText, mContentIntent); - //create the content which is shown in the notification pulldown - mContentTitle = fileName;; //Full title of the notification in the pull down + //add the additional content and intent to the notification mNotification.setLatestEventInfo(mContext, mContentTitle, contentText, mContentIntent); diff --git a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/FileDownloaderAsyncTask.java b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/FileDownloaderAsyncTask.java index 904b2424..c3b1c723 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/FileDownloaderAsyncTask.java +++ b/SWADroid/src/es/ugr/swad/swadroid/modules/downloads/FileDownloaderAsyncTask.java @@ -189,6 +189,14 @@ public class FileDownloaderAsyncTask extends AsyncTask { ucon = url.openConnection(); } catch (IOException e) { //Log.i(TAG, "Error connection"); + try { + fos.close(); + } catch (IOException e1) { + //Log.i(TAG, "no se puede cerrar fichero de salida"); + e1.printStackTrace(); + notifyFailed(); + return false; + } e.printStackTrace(); notifyFailed(); return false; @@ -202,6 +210,14 @@ public class FileDownloaderAsyncTask extends AsyncTask { is = ucon.getInputStream(); } catch (IOException e) { //Log.i(TAG, "Error connection"); + try { + fos.close(); + } catch (IOException e1) { + //Log.i(TAG, "no se puede cerrar fichero de salida"); + e1.printStackTrace(); + notifyFailed(); + return false; + } notifyFailed(); e.printStackTrace(); return false; @@ -211,14 +227,6 @@ public class FileDownloaderAsyncTask extends AsyncTask { /* Read bytes to the buffer until there is nothing more to read(-1) */ ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; - int total = 100; - try { - total = bis.available(); - } catch (IOException e1) { - Log.i(TAG, "Error lectura bytes");mNotification.eraseNotification(this.fileName); - e1.printStackTrace(); - }; - if(notification){ @@ -234,6 +242,14 @@ public class FileDownloaderAsyncTask extends AsyncTask { baf.clear(); } catch (IOException e) { // Log.i(TAG, "no se puede escribir fichero de salida"); + try { + fos.close(); + } catch (IOException e1) { + //Log.i(TAG, "no se puede cerrar fichero de salida"); + e1.printStackTrace(); + notifyFailed(); + return false; + } notifyFailed(); e.printStackTrace(); return false;