Skip to content

Commit

Permalink
Remove legacy code, available offline will be synced via workmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Jul 18, 2022
1 parent ea09a91 commit 5db221e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 353 deletions.
3 changes: 0 additions & 3 deletions owncloudApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter_files" />
</service>
<service
android:name=".files.services.AvailableOfflineSyncJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />

<provider
android:name=".providers.FileContentProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import android.database.Cursor
import android.net.Uri
import android.os.RemoteException
import androidx.core.util.Pair
import com.owncloud.android.datamodel.OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE_PARENT
import com.owncloud.android.datamodel.OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CAPABILITIES_DAV_CHUNKING_VERSION
Expand Down Expand Up @@ -64,7 +62,6 @@ import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CAPABILITIES_VERSI
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CONTENT_URI
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.CONTENT_URI_CAPABILITIES
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.FILE_KEEP_IN_SYNC
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta.FILE_PATH
import com.owncloud.android.domain.capabilities.model.CapabilityBooleanType
import com.owncloud.android.domain.capabilities.model.OCCapability
Expand Down Expand Up @@ -109,55 +106,6 @@ class FileDataStorageManager : KoinComponent {
mContext = activity
}

/**
* Get a collection with all the files set by the user as available offline, from all the accounts
* in the device, putting away the folders
*
*
* This is the only method working with a NULL account in [.mAccount]. Not something to do often.
*
* @return List with all the files set by the user as available offline.
*/
fun getAvailableOfflineFilesFromEveryAccount(): List<Pair<OCFile, String>> {
return listOf()
// FIXME: 13/10/2020 : New_arch: Av.Offline
// val result = ArrayList<Pair<OCFile, String>>()
// var cursorOnKeptInSync: Cursor? = null
// try {
// cursorOnKeptInSync = performQuery(
// uri = CONTENT_URI,
// projection = null,
// selection = "$FILE_KEEP_IN_SYNC = ? OR $FILE_KEEP_IN_SYNC = ?",
// selectionArgs = arrayOf(AVAILABLE_OFFLINE.value.toString(), AVAILABLE_OFFLINE_PARENT.value.toString()),
// sortOrder = null,
// performWithContentProviderClient = false
// )
//
// if (cursorOnKeptInSync != null && cursorOnKeptInSync.moveToFirst()) {
// var file: OCFile?
// var accountName: String
// do {
// file = createFileInstance(cursorOnKeptInSync)
// accountName =
// cursorOnKeptInSync.getStringFromColumnOrEmpty(FILE_ACCOUNT_OWNER)
// if (!file!!.isFolder && AccountUtils.exists(accountName, mContext)) {
// result.add(Pair(file, accountName))
// }
// } while (cursorOnKeptInSync.moveToNext())
// } else {
// Timber.d("No available offline files found")
// }
//
// } catch (e: Exception) {
// Timber.e(e, "Exception retrieving all the available offline files")
//
// } finally {
// cursorOnKeptInSync?.close()
// }
//
// return result
}

fun sharedByLinkFilesFromCurrentAccount(): List<OCFile>? = runBlocking(CoroutinesDispatcherProvider().io) {
val getFilesSharedByLinkUseCase: GetFilesSharedByLinkUseCase by inject()

Expand Down Expand Up @@ -506,37 +454,6 @@ class FileDataStorageManager : KoinComponent {
result ?: listOf()
}

/**
* Checks if it is favorite or it is inside a favorite folder
*
* @param file [OCFile] which ancestors will be searched.
* @return true/false
*/
// FIXME: 13/10/2020 : New_arch: Av.Offline
private fun isAnyAncestorAvailableOfflineFolder(file: OCFile) = false //getAvailableOfflineAncestorOf(file) != null

/**
* Returns ancestor folder with available offline status AVAILABLE_OFFLINE.
*
* @param file [OCFile] which ancestors will be searched.
* @return Ancestor folder with available offline status AVAILABLE_OFFLINE, or null if
* does not exist.
*/
// FIXME: 13/10/2020 : New_arch: Av.Offline
private fun getAvailableOfflineAncestorOf(file: OCFile): OCFile? {
return null
// var avOffAncestor: OCFile? = null
// val parent = getFileById(file.parentId)
// if (parent != null && parent.isFolder) { // file is null for the parent of the root folder
// if (parent.availableOfflineStatus == AVAILABLE_OFFLINE) {
// avOffAncestor = parent
// } else if (parent.fileName != ROOT_PATH) {
// avOffAncestor = getAvailableOfflineAncestorOf(parent)
// }
// }
// return avOffAncestor
}

// FIXME: 13/10/2020 : New_arch: Migration
private fun createFileInstance(c: Cursor?): OCFile? = null//c?.let {
// OCFile(it.getStringFromColumnOrThrow(FILE_PATH)).apply {
Expand Down Expand Up @@ -840,13 +757,6 @@ class FileDataStorageManager : KoinComponent {
)
}

// FIXME: 13/10/2020 : New_arch: Av.Offline
private fun selectionForAllDescendantsOf(file: OCFile): Pair<String, Array<String>> {
val selection = "$FILE_ACCOUNT_OWNER=? AND $FILE_PATH LIKE ? "
val selectionArgs = arrayOf(account.name, "${file.remotePath}_%") // one or more characters after remote path
return Pair(selection, selectionArgs)
}

private fun performQuery(
uri: Uri,
projection: Array<String>?,
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5db221e

Please sign in to comment.