Update image of play/pause button when audio playback starts
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileDownloader.java
index d3317d8..d8fa84b 100644 (file)
@@ -36,6 +36,8 @@ import com.owncloud.android.operations.DownloadFileOperation;
 import com.owncloud.android.operations.RemoteOperationResult;\r
 import com.owncloud.android.ui.activity.FileDetailActivity;\r
 import com.owncloud.android.ui.fragment.FileDetailFragment;\r
+import com.owncloud.android.ui.preview.PreviewImageActivity;\r
+import com.owncloud.android.ui.preview.PreviewImageFragment;\r
 \r
 import android.accounts.Account;\r
 import android.app.Notification;\r
@@ -53,6 +55,7 @@ import android.os.Process;
 import android.util.Log;\r
 import android.widget.RemoteViews;\r
 \r
+import com.owncloud.android.AccountUtils;\r
 import com.owncloud.android.R;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
@@ -400,7 +403,12 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);\r
         \r
         /// includes a pending intent in the notification showing the details view of the file\r
-        Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);\r
+        Intent showDetailsIntent = null;\r
+        if (PreviewImageFragment.canBePreviewed(download.getFile())) {\r
+            showDetailsIntent = new Intent(this, PreviewImageActivity.class);\r
+        } else {\r
+            showDetailsIntent = new Intent(this, FileDetailActivity.class);\r
+        }\r
         showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, download.getFile());\r
         showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, download.getAccount());\r
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r
@@ -448,8 +456,22 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
             int contentId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content;\r
             Notification finalNotification = new Notification(R.drawable.icon, getString(tickerId), System.currentTimeMillis());\r
             finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;\r
-            // TODO put something smart in the contentIntent below\r
-            finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);\r
+            Intent showDetailsIntent = null;\r
+            if (downloadResult.isSuccess()) {\r
+                if (PreviewImageFragment.canBePreviewed(download.getFile())) {\r
+                    showDetailsIntent = new Intent(this, PreviewImageActivity.class);\r
+                } else {\r
+                    showDetailsIntent = new Intent(this, FileDetailActivity.class);\r
+                }\r
+                showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, download.getFile());\r
+                showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, download.getAccount());\r
+                showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r
+                \r
+            } else {\r
+                // TODO put something smart in showDetailsIntent\r
+                showDetailsIntent = new Intent();\r
+            }\r
+            finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);\r
             finalNotification.setLatestEventInfo(getApplicationContext(), getString(tickerId), String.format(getString(contentId), new File(download.getSavePath()).getName()), finalNotification.contentIntent);\r
             mNotificationManager.notify(tickerId, finalNotification);\r
         }\r