import android.widget.RemoteViews;
import com.owncloud.android.Log_OC;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import eu.alefzero.webdav.WebdavClient;
public static final String EXTRA_ACCOUNT = "ACCOUNT";
public static final String EXTRA_FILE = "FILE";
- public static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
- public static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
+ private static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
+ private static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
public static final String EXTRA_DOWNLOAD_RESULT = "RESULT";
public static final String EXTRA_FILE_PATH = "FILE_PATH";
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
private int mLastPercent;
+ public String getDownloadAddedMessage() {
+ return getClass().getName().toString() + DOWNLOAD_ADDED_MESSAGE;
+ }
+
+ public String getDownloadFinishMessage() {
+ return getClass().getName().toString() + DOWNLOAD_FINISH_MESSAGE;
+ }
+
/**
* Builds a key for mPendingDownloads from the account and file to download
*
if (account == null || file == null) return false;
String targetKey = buildRemoteName(account, file);
synchronized (mPendingDownloads) {
- if (file.isDirectory()) {
+ if (file.isFolder()) {
// this can be slow if there are many downloads :(
Iterator<String> it = mPendingDownloads.keySet().iterator();
boolean found = false;
int contentId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content;
Notification finalNotification = new Notification(R.drawable.icon, getString(tickerId), System.currentTimeMillis());
finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
- boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED);
+ boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
+ // (downloadResult.isTemporalRedirection() && downloadResult.isIdPRedirection()
+ (downloadResult.isIdPRedirection()
+ && MainApp.getAuthTokenTypeSamlSessionCookie().equals(mDownloadClient.getAuthTokenType())));
if (needsToUpdateCredentials) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
+ updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
* @param downloadResult Result of the download operation
*/
private void sendBroadcastDownloadFinished(DownloadFileOperation download, RemoteOperationResult downloadResult) {
- Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE);
+ Intent end = new Intent(getDownloadFinishMessage());
end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());
end.putExtra(ACCOUNT_NAME, download.getAccount().name);
end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
* @param download Added download operation
*/
private void sendBroadcastNewDownload(DownloadFileOperation download) {
- Intent added = new Intent(DOWNLOAD_ADDED_MESSAGE);
+ Intent added = new Intent(getDownloadAddedMessage());
added.putExtra(ACCOUNT_NAME, download.getAccount().name);
added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
added.putExtra(EXTRA_FILE_PATH, download.getSavePath());