Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(myKSuite-storage): Update NotEnoughStorageView with new bottomsheet #1534

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/src/main/java/com/infomaniak/drive/data/api/ApiRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,6 @@ object ApiRoutes {

/** Others */
//region Others
fun upgradeDrive(driveId: Int) = "${SHOP_URL}drive/$driveId"

fun orderDrive() = "${SHOP_URL}drive"

fun renewDrive(accountId: Int) = "${MANAGER_URL}$accountId/accounts/accounting/renewal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ open class Drive(
inline val isMyKSuitePack get() = pack?.type == DrivePack.DrivePackType.MY_KSUITE
inline val isMyKSuitePlusPack get() = pack?.type == DrivePack.DrivePackType.MY_KSUITE_PLUS
inline val isFreeTier get() = isFreePack || isMyKSuitePack
inline val isSingleUserDrive get() = isFreeTier || isMyKSuitePlusPack || isSoloPack

inline val isTechnicalMaintenance get() = maintenanceReason == MaintenanceReason.TECHNICAL.value

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/infomaniak/drive/utils/AccountUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ object AccountUtils : CredentialManager() {
fun isEnableAppSync(): Boolean = UploadFile.getAppSyncSettings() != null

fun getPersonalFolderTitle(context: Context): String {
val isSingleUserDrive = getCurrentDrive()?.let { it.isFreeTier || it.isMyKSuitePlusPack || it.isSoloPack } ?: false

return if (isSingleUserDrive) {
context.getString(R.string.localizedFilenamePrivateSpace)
val folderTitle = if (getCurrentDrive()?.isSingleUserDrive == true) {
R.string.localizedFilenamePrivateSpace
} else {
context.getString(R.string.localizedFilenamePrivateTeamSpace)
R.string.localizedFilenamePrivateTeamSpace
}

return context.getString(folderTitle)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ import android.view.LayoutInflater
import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.navigation.findNavController
import com.infomaniak.core.myksuite.ui.screens.KSuiteApp
import com.infomaniak.core.myksuite.ui.utils.MyKSuiteUiUtils.openMyKSuiteUpgradeBottomSheet
import com.infomaniak.drive.R
import com.infomaniak.drive.data.api.ApiRoutes
import com.infomaniak.drive.data.models.drive.Drive
import com.infomaniak.drive.data.models.drive.DrivePack
import com.infomaniak.drive.databinding.ViewNotEnoughStorageBinding
import com.infomaniak.drive.utils.AccountUtils
import com.infomaniak.drive.utils.formatShortBinarySize
import com.infomaniak.lib.core.utils.UtilsUi.openUrl

class NotEnoughStorageView @JvmOverloads constructor(
context: Context,
Expand All @@ -44,7 +43,7 @@ class NotEnoughStorageView @JvmOverloads constructor(
@SuppressLint("SetTextI18n")
fun setup(currentDrive: Drive) = with(binding) {
currentDrive.apply {
val storagePercentage = if (size > 0L) (usedSize.toFloat() / size) * 100.0f else 0.0f
val storagePercentage = if (size > 0L) (usedSize.toDouble() / size).toFloat() * 100.0f else 0.0f
if (storagePercentage > STORAGE_ALERT_MIN_PERCENTAGE) {
[email protected] = true

Expand All @@ -53,18 +52,13 @@ class NotEnoughStorageView @JvmOverloads constructor(
progressIndicator.progress = (storagePercentage).toInt()
title.text = "$usedStorage / $totalStorage"

when (pack?.type) {
DrivePack.DrivePackType.SOLO, DrivePack.DrivePackType.FREE -> {
description.setText(R.string.notEnoughStorageDescription1)
upgradeOffer.isVisible = true
upgradeOffer.setOnClickListener {
context.openUrl(ApiRoutes.upgradeDrive(AccountUtils.currentDriveId))
}
}
else -> {
description.setText(R.string.notEnoughStorageDescription2)
upgradeOffer.isGone = true
}
if (isSingleUserDrive) {
description.setText(R.string.notEnoughStorageDescription1)
upgradeOffer.isVisible = true
upgradeOffer.setOnClickListener { findNavController().openMyKSuiteUpgradeBottomSheet(KSuiteApp.Drive) }
} else {
description.setText(R.string.notEnoughStorageDescription2)
upgradeOffer.isGone = true
}

close.setOnClickListener {
Expand Down