version bump
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / files / services / FileDownloader.java
index 087b103..c051fc1 100644 (file)
@@ -1,6 +1,7 @@
 package eu.alefzero.owncloud.files.services;\r
 \r
 import java.io.File;\r
 package eu.alefzero.owncloud.files.services;\r
 \r
 import java.io.File;\r
+import java.io.IOException;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
@@ -123,13 +124,20 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);\r
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, mTotalDownloadSize == -1);\r
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);\r
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);\r
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, mTotalDownloadSize == -1);\r
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);\r
+        // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;\r
+        //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on a download in the notification bar\r
+        mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);\r
         \r
         mNotificationMngr.notify(1, mNotification);\r
 \r
         File sdCard = Environment.getExternalStorageDirectory();\r
         \r
         mNotificationMngr.notify(1, mNotification);\r
 \r
         File sdCard = Environment.getExternalStorageDirectory();\r
-        File dir = new File(sdCard.getAbsolutePath() + "/owncloud");\r
-        dir.mkdirs();\r
-        File file = new File(dir, mFilePath.replace('/', '.'));\r
+        File file = new File(sdCard.getAbsolutePath() + "/owncloud/" + mAccount.name + mFilePath);\r
+        try {\r
+            file.getParentFile().mkdirs();\r
+            file.createNewFile();\r
+        } catch (IOException e) {\r
+            e.printStackTrace();\r
+        }\r
 \r
         Log.e(TAG, file.getAbsolutePath() + " " + oc_url.toString());\r
         Log.e(TAG, mFilePath+"");\r
 \r
         Log.e(TAG, file.getAbsolutePath() + " " + oc_url.toString());\r
         Log.e(TAG, mFilePath+"");\r
@@ -147,6 +155,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         }\r
         mNotificationMngr.cancel(1);\r
         Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE);\r
         }\r
         mNotificationMngr.cancel(1);\r
         Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE);\r
+        end.putExtra(EXTRA_FILE_PATH, file.getAbsolutePath());\r
         sendBroadcast(end);\r
     }\r
 \r
         sendBroadcast(end);\r
     }\r
 \r