mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Implement FilesDownloadWorker
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
dcbf89c3d2
commit
b804258790
2 changed files with 26 additions and 13 deletions
|
@ -49,7 +49,6 @@ import com.owncloud.android.authentication.AuthenticatorActivity
|
||||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||||
import com.owncloud.android.datamodel.OCFile
|
import com.owncloud.android.datamodel.OCFile
|
||||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||||
import com.owncloud.android.files.services.FileDownloader
|
|
||||||
import com.owncloud.android.files.services.IndexedForest
|
import com.owncloud.android.files.services.IndexedForest
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient
|
import com.owncloud.android.lib.common.OwnCloudClient
|
||||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||||
|
@ -93,6 +92,12 @@ class FilesDownloadWorker(
|
||||||
const val ACTIVITY_NAME = "ACTIVITY_NAME"
|
const val ACTIVITY_NAME = "ACTIVITY_NAME"
|
||||||
const val PACKAGE_NAME = "PACKAGE_NAME"
|
const val PACKAGE_NAME = "PACKAGE_NAME"
|
||||||
const val CONFLICT_UPLOAD_ID = "CONFLICT_UPLOAD_ID"
|
const val CONFLICT_UPLOAD_ID = "CONFLICT_UPLOAD_ID"
|
||||||
|
const val EXTRA_USER = "USER"
|
||||||
|
const val EXTRA_FILE = "FILE"
|
||||||
|
const val EXTRA_DOWNLOAD_RESULT = "RESULT"
|
||||||
|
const val EXTRA_REMOTE_PATH = "REMOTE_PATH"
|
||||||
|
const val EXTRA_LINKED_TO_PATH = "LINKED_TO"
|
||||||
|
const val ACCOUNT_NAME = "ACCOUNT_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
private var notification: Notification? = null
|
private var notification: Notification? = null
|
||||||
|
@ -257,15 +262,15 @@ class FilesDownloadWorker(
|
||||||
downloadResult: RemoteOperationResult<*>,
|
downloadResult: RemoteOperationResult<*>,
|
||||||
unlinkedFromRemotePath: String?
|
unlinkedFromRemotePath: String?
|
||||||
) {
|
) {
|
||||||
val end = Intent(FileDownloader.getDownloadFinishMessage())
|
val end = Intent(getDownloadFinishMessage())
|
||||||
end.putExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess)
|
end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess)
|
||||||
end.putExtra(FileDownloader.ACCOUNT_NAME, download.user.accountName)
|
end.putExtra(ACCOUNT_NAME, download.user.accountName)
|
||||||
end.putExtra(FileDownloader.EXTRA_REMOTE_PATH, download.remotePath)
|
end.putExtra(EXTRA_REMOTE_PATH, download.remotePath)
|
||||||
end.putExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR, download.behaviour)
|
end.putExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR, download.behaviour)
|
||||||
end.putExtra(SendShareDialog.ACTIVITY_NAME, download.activityName)
|
end.putExtra(SendShareDialog.ACTIVITY_NAME, download.activityName)
|
||||||
end.putExtra(SendShareDialog.PACKAGE_NAME, download.packageName)
|
end.putExtra(SendShareDialog.PACKAGE_NAME, download.packageName)
|
||||||
if (unlinkedFromRemotePath != null) {
|
if (unlinkedFromRemotePath != null) {
|
||||||
end.putExtra(FileDownloader.EXTRA_LINKED_TO_PATH, unlinkedFromRemotePath)
|
end.putExtra(EXTRA_LINKED_TO_PATH, unlinkedFromRemotePath)
|
||||||
}
|
}
|
||||||
end.setPackage(context.packageName)
|
end.setPackage(context.packageName)
|
||||||
localBroadcastManager.sendBroadcast(end)
|
localBroadcastManager.sendBroadcast(end)
|
||||||
|
@ -417,14 +422,22 @@ class FilesDownloadWorker(
|
||||||
pendingDownloads.remove(accountName)
|
pendingDownloads.remove(accountName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDownloadAddedMessage(): String {
|
||||||
|
return FilesDownloadWorker::class.java.name + "DOWNLOAD_ADDED"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDownloadFinishMessage(): String {
|
||||||
|
return FilesDownloadWorker::class.java.name + "DOWNLOAD_FINISH"
|
||||||
|
}
|
||||||
|
|
||||||
private fun sendBroadcastNewDownload(
|
private fun sendBroadcastNewDownload(
|
||||||
download: DownloadFileOperation,
|
download: DownloadFileOperation,
|
||||||
linkedToRemotePath: String
|
linkedToRemotePath: String
|
||||||
) {
|
) {
|
||||||
val added = Intent(FileDownloader.getDownloadAddedMessage())
|
val added = Intent(getDownloadAddedMessage())
|
||||||
added.putExtra(FileDownloader.ACCOUNT_NAME, download.user.accountName)
|
added.putExtra(ACCOUNT_NAME, download.user.accountName)
|
||||||
added.putExtra(FileDownloader.EXTRA_REMOTE_PATH, download.remotePath)
|
added.putExtra(EXTRA_REMOTE_PATH, download.remotePath)
|
||||||
added.putExtra(FileDownloader.EXTRA_LINKED_TO_PATH, linkedToRemotePath)
|
added.putExtra(EXTRA_LINKED_TO_PATH, linkedToRemotePath)
|
||||||
added.setPackage(context.packageName)
|
added.setPackage(context.packageName)
|
||||||
localBroadcastManager.sendBroadcast(added)
|
localBroadcastManager.sendBroadcast(added)
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,11 @@ public class FileDownloader implements OnDatatransferProgressListener, OnAccount
|
||||||
private final Context context = MainApp.getAppContext();
|
private final Context context = MainApp.getAppContext();
|
||||||
private final Intent intent;
|
private final Intent intent;
|
||||||
|
|
||||||
public static final String EXTRA_USER = "USER";
|
|
||||||
public static final String EXTRA_FILE = "FILE";
|
|
||||||
|
|
||||||
private static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
|
private static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
|
||||||
private static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
|
private static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
|
||||||
|
|
||||||
|
public static final String EXTRA_USER = "USER";
|
||||||
|
public static final String EXTRA_FILE = "FILE";
|
||||||
public static final String EXTRA_DOWNLOAD_RESULT = "RESULT";
|
public static final String EXTRA_DOWNLOAD_RESULT = "RESULT";
|
||||||
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
|
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
|
||||||
public static final String EXTRA_LINKED_TO_PATH = "LINKED_TO";
|
public static final String EXTRA_LINKED_TO_PATH = "LINKED_TO";
|
||||||
|
|
Loading…
Reference in a new issue