-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download files iin new file manager (#994)
**Background** Add file downloading into new file manager **Changes** - Fix bug when size of file during download could not calculate - Fixed coroutine cancellation with channel.receive - Add downloading for file **Test plan** - Open some folder, try download file and share it - Open some folder, start download file and cancel it --------- Co-authored-by: Nikita Kulikov <[email protected]>
- Loading branch information
1 parent
7af93e0
commit 8b325fd
Showing
38 changed files
with
739 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
...nts/core/share/src/androidMain/kotlin/com/flipperdevices/core/share/AndroidShareHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.flipperdevices.core.share | ||
|
||
import android.content.Context | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import okio.Path.Companion.toOkioPath | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(AppGraph::class, PlatformShareHelper::class) | ||
class AndroidShareHelper @Inject constructor( | ||
private val context: Context | ||
) : PlatformShareHelper { | ||
|
||
override fun provideSharableFile(fileName: String): PlatformSharableFile { | ||
val path = SharableFile(context, fileName).toOkioPath() | ||
return PlatformSharableFile(path) | ||
} | ||
|
||
override fun shareFile(file: PlatformSharableFile, title: String) { | ||
ShareHelper.shareFile( | ||
context = context, | ||
file = file, | ||
text = title | ||
) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
...ts/core/share/src/commonMain/kotlin/com/flipperdevices/core/share/PlatformSharableFile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.flipperdevices.core.share | ||
|
||
import okio.Path | ||
|
||
/** | ||
* This class should be only created via [PlatformShareHelper] due | ||
* to permission restrictions. On android we can share files only in | ||
* specified folder specified in AndroidManifest | ||
*/ | ||
class PlatformSharableFile internal constructor(val path: Path) |
16 changes: 16 additions & 0 deletions
16
...nts/core/share/src/commonMain/kotlin/com/flipperdevices/core/share/PlatformShareHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.flipperdevices.core.share | ||
|
||
interface PlatformShareHelper { | ||
/** | ||
* Provide file which can be shared later via [shareFile] | ||
* | ||
* If file with same name [fileName] exists, it will be deleted | ||
*/ | ||
fun provideSharableFile(fileName: String): PlatformSharableFile | ||
|
||
/** | ||
* @param file file to share | ||
* @param title text displayed as hint for user | ||
*/ | ||
fun shareFile(file: PlatformSharableFile, title: String) | ||
} |
17 changes: 17 additions & 0 deletions
17
...nts/core/share/src/desktopMain/kotlin/com/flipperdevices/core/share/DesktopShareHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.flipperdevices.core.share | ||
|
||
import com.flipperdevices.core.di.AppGraph | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(AppGraph::class, PlatformShareHelper::class) | ||
class DesktopShareHelper @Inject constructor() : PlatformShareHelper { | ||
|
||
override fun provideSharableFile(fileName: String): PlatformSharableFile { | ||
error("The desktop feature is not yet implemented!") | ||
} | ||
|
||
override fun shareFile(file: PlatformSharableFile, title: String) { | ||
error("The desktop feature is not yet implemented!") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.filemanager.download.api" | ||
|
||
commonDependencies { | ||
implementation(projects.components.core.ui.decompose) | ||
|
||
implementation(libs.compose.ui) | ||
implementation(libs.decompose) | ||
|
||
implementation(libs.okio) | ||
} |
25 changes: 25 additions & 0 deletions
25
...mmonMain/kotlin/com/flipperdevices/filemanager/download/api/DownloadDecomposeComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.flipperdevices.filemanager.download.api | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.ui.decompose.ScreenDecomposeComponent | ||
import kotlinx.coroutines.flow.StateFlow | ||
import okio.Path | ||
|
||
abstract class DownloadDecomposeComponent( | ||
componentContext: ComponentContext | ||
) : ScreenDecomposeComponent(componentContext) { | ||
abstract val isInProgress: StateFlow<Boolean> | ||
|
||
abstract fun onCancel() | ||
|
||
abstract fun download( | ||
fullPath: Path, | ||
size: Long | ||
) | ||
|
||
fun interface Factory { | ||
operator fun invoke( | ||
componentContext: ComponentContext, | ||
): DownloadDecomposeComponent | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
plugins { | ||
id("flipper.multiplatform-compose") | ||
id("flipper.multiplatform-dependencies") | ||
id("flipper.anvil-multiplatform") | ||
id("kotlinx-serialization") | ||
} | ||
android.namespace = "com.flipperdevices.filemanager.download.impl" | ||
|
||
commonDependencies { | ||
implementation(projects.components.core.di) | ||
implementation(projects.components.core.ktx) | ||
implementation(projects.components.core.log) | ||
|
||
implementation(projects.components.core.ui.lifecycle) | ||
implementation(projects.components.core.ui.theme) | ||
implementation(projects.components.core.ui.decompose) | ||
implementation(projects.components.core.ui.ktx) | ||
implementation(projects.components.core.ui.res) | ||
implementation(projects.components.core.share) | ||
implementation(projects.components.core.storage) | ||
implementation(projects.components.core.progress) | ||
|
||
implementation(projects.components.bridge.connection.feature.common.api) | ||
implementation(projects.components.bridge.connection.transport.common.api) | ||
implementation(projects.components.bridge.connection.feature.provider.api) | ||
implementation(projects.components.bridge.connection.feature.storage.api) | ||
implementation(projects.components.bridge.connection.feature.storageinfo.api) | ||
implementation(projects.components.bridge.connection.feature.serialspeed.api) | ||
implementation(projects.components.bridge.connection.feature.rpcinfo.api) | ||
implementation(projects.components.bridge.dao.api) | ||
|
||
implementation(projects.components.filemngr.download.api) | ||
|
||
// Compose | ||
implementation(libs.compose.ui) | ||
implementation(libs.compose.tooling) | ||
implementation(libs.compose.foundation) | ||
implementation(libs.compose.material) | ||
|
||
implementation(libs.decompose) | ||
implementation(libs.kotlin.coroutines) | ||
implementation(libs.essenty.lifecycle) | ||
implementation(libs.essenty.lifecycle.coroutines) | ||
|
||
implementation(libs.bundles.decompose) | ||
implementation(libs.okio) | ||
implementation(libs.kotlin.immutable.collections) | ||
} |
Oops, something went wrong.