Skip to content

Commit

Permalink
Fix new file manager issues (#998)
Browse files Browse the repository at this point in the history
**Background**

This PR introduces fixes for small variousnew  file manager issues

**Changes**

- Fix download file
- Share ProgressScreen between modules
- Fix animateions on ProgressScreen
- Add temporary error screen(until errors design is completed)
- Fix selection after item deleted

**Test plan**

- Try use new file manager with all it's functionality
  • Loading branch information
makeevrserg authored Dec 4, 2024
1 parent 57d93f6 commit 30d085b
Show file tree
Hide file tree
Showing 43 changed files with 562 additions and 724 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [FIX] Fix empty response in faphub category
- [FIX] New file manager uploading progress
- [FIX] Fix build when no metrics enabled
- [FIX] Fix small issues with new file manager

# 1.8.0
Attention: don't forget to add the flag for F-Droid before release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.flipperdevices.core.share

import android.content.Context
import com.flipperdevices.core.di.AppGraph
import com.flipperdevices.core.ktx.jre.createClearNewFileWithMkDirs
import com.squareup.anvil.annotations.ContributesBinding
import okio.Path.Companion.toOkioPath
import javax.inject.Inject
Expand All @@ -12,8 +13,9 @@ class AndroidShareHelper @Inject constructor(
) : PlatformShareHelper {

override fun provideSharableFile(fileName: String): PlatformSharableFile {
val path = SharableFile(context, fileName).toOkioPath()
return PlatformSharableFile(path)
val sharableFile = SharableFile(context, fileName)
sharableFile.createClearNewFileWithMkDirs()
return PlatformSharableFile(sharableFile.toOkioPath())
}

override fun shareFile(file: PlatformSharableFile, title: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.flipperdevices.filemanager.download.api

import com.arkivanov.decompose.ComponentContext
import com.flipperdevices.filemanager.download.model.DownloadableFile
import com.flipperdevices.ui.decompose.ScreenDecomposeComponent
import kotlinx.coroutines.flow.StateFlow
import okio.Path

abstract class DownloadDecomposeComponent(
componentContext: ComponentContext
Expand All @@ -12,10 +12,7 @@ abstract class DownloadDecomposeComponent(

abstract fun onCancel()

abstract fun download(
fullPath: Path,
size: Long
)
abstract fun download(file: DownloadableFile)

fun interface Factory {
operator fun invoke(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.flipperdevices.filemanager.download.model

import okio.Path

data class DownloadableFile(
val fullPath: Path,
val size: Long
)
1 change: 1 addition & 0 deletions components/filemngr/download/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ commonDependencies {
implementation(projects.components.bridge.dao.api)

implementation(projects.components.filemngr.download.api)
implementation(projects.components.filemngr.uiComponents)

// Compose
implementation(libs.compose.ui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ import com.flipperdevices.core.di.AppGraph
import com.flipperdevices.core.ui.theme.LocalPalletV2
import com.flipperdevices.filemanager.download.api.DownloadDecomposeComponent
import com.flipperdevices.filemanager.download.impl.composable.DownloadingComposable
import com.flipperdevices.filemanager.download.impl.model.DownloadableFile
import com.flipperdevices.filemanager.download.impl.viewmodel.DownloadViewModel
import com.flipperdevices.filemanager.download.model.DownloadableFile
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import me.gulya.anvil.assisted.ContributesAssistedFactory
import okio.Path
import javax.inject.Provider

@ContributesAssistedFactory(AppGraph::class, DownloadDecomposeComponent.Factory::class)
Expand All @@ -42,15 +41,9 @@ class DownloadDecomposeComponentImpl @AssistedInject constructor(

override fun onCancel() = downloadViewModel.onCancel()

override fun download(
fullPath: Path,
size: Long
) = downloadViewModel.tryDownload(
file = DownloadableFile(
fullPath = fullPath,
size = size
)
)
override fun download(file: DownloadableFile) {
downloadViewModel.tryDownload(file = file)
}

@Composable
override fun Render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
package com.flipperdevices.filemanager.download.impl.composable

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.flipperdevices.core.ui.ktx.clickableRipple
import com.flipperdevices.core.ui.theme.LocalPalletV2
import com.flipperdevices.core.ui.theme.LocalTypography
import com.flipperdevices.core.ktx.jre.toFormattedSize
import com.flipperdevices.filemanager.download.impl.viewmodel.DownloadViewModel
import com.flipperdevices.filemanager.ui.components.transfer.FileTransferFullScreenComposable
import flipperapp.components.filemngr.download.impl.generated.resources.fm_cancel
import flipperapp.components.filemngr.download.impl.generated.resources.fm_downloading
import flipperapp.components.filemngr.download.impl.generated.resources.fm_in_progress_file_size
import flipperapp.components.filemngr.download.impl.generated.resources.fm_in_progress_speed
import org.jetbrains.compose.resources.stringResource
import flipperapp.components.filemngr.download.impl.generated.resources.Res as FDR

Expand All @@ -29,38 +18,24 @@ fun DownloadingComposable(
onCancel: () -> Unit,
modifier: Modifier = Modifier
) {
Box(
modifier = modifier
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column(
verticalArrangement = Arrangement.SpaceBetween,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize()
) {
Text(
text = stringResource(FDR.string.fm_downloading),
style = LocalTypography.current.titleB18,
color = LocalPalletV2.current.text.title.primary,
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center
)

Text(
text = stringResource(FDR.string.fm_cancel),
style = LocalTypography.current.bodyM14,
color = LocalPalletV2.current.action.danger.text.default,
modifier = Modifier
.fillMaxWidth()
.padding(12.dp)
.clip(RoundedCornerShape(12.dp))
.clickableRipple(onClick = onCancel),
textAlign = TextAlign.Center
FileTransferFullScreenComposable(
modifier = modifier,
title = stringResource(FDR.string.fm_downloading),
actionText = stringResource(FDR.string.fm_cancel),
onActionClick = onCancel,
progressTitle = state.fullPath.name,
progress = if (state.totalSize == 0L) 0f else state.downloadedSize / state.totalSize.toFloat(),
progressText = stringResource(
FDR.string.fm_in_progress_file_size,
state.downloadedSize.toFormattedSize(),
state.totalSize.toFormattedSize()
),
speedText = when (state.downloadSpeed) {
0L -> null
else -> stringResource(
FDR.string.fm_in_progress_speed,
state.downloadSpeed.toFormattedSize(),
)
}
InProgressComposable(
state = state,
)
}
)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.flipperdevices.core.log.LogTagProvider
import com.flipperdevices.core.log.error
import com.flipperdevices.core.share.PlatformShareHelper
import com.flipperdevices.core.ui.lifecycle.DecomposeViewModel
import com.flipperdevices.filemanager.download.impl.model.DownloadableFile
import com.flipperdevices.filemanager.download.model.DownloadableFile
import flipperapp.components.filemngr.download.impl.generated.resources.Res
import flipperapp.components.filemngr.download.impl.generated.resources.fm_share_title
import kotlinx.coroutines.Dispatchers
Expand All @@ -25,7 +25,6 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
Expand Down Expand Up @@ -53,7 +52,6 @@ class DownloadViewModel @Inject constructor(
pathOnFlipper = flipperFileFullPath.toString(),
fileOnAndroid = pathOnAndroid.path,
progressListener = { current, max ->
println("DownloadViewModel progressListener")
_state.update { state ->
(state as? State.Downloading)
?.copy(downloadedSize = current, totalSize = max)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<string name="fme_save_as_file">Save File as...</string>
<string name="fme_save">Save</string>
<string name="fme_status_downloading">Downloading...</string>
<string name="fme_status_uploading">Uploading: %1$s [%2$s/%3$s]</string>
<string name="fme_status_uploading">Uploading...</string>
<string name="fme_status_speed">Speed: %1$s/s</string>
<string name="fme_cancel">Cancel</string>
<string name="fme_allowed_characters">Allowed characters: %1$s</string>
Expand All @@ -13,4 +13,6 @@
<string name="fme_save_as_dialog_title">Enter name:</string>
<string name="fme_save_as_dialog_button">Save as New File</string>
<string name="fme_save_as_dialog_chars">Allowed Characters: %1$s</string>
<string name="fme_error_too_large_title">The file is too large!</string>
<string name="fme_error_too_large_desc">Unfortunately, flipper Android doesn't allow to edit files larger: %1$s</string>
</resources>
Loading

0 comments on commit 30d085b

Please sign in to comment.