Skip to content

Commit

Permalink
chore(MyKSuite): Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Feb 21, 2025
1 parent 4612f19 commit ad604cf
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object ApiRoutes {
"with=drives,users,teams,teams.users,teams.users_count,drives.capabilities,drives.preferences," +
"drives.pack,drives.pack.capabilities,drives.pack.limits,drive.limits,drives.settings,drives.k_suite,drives.tags," +
"drives.rights,drives.categories,drives.categories_permissions,drives.users,drives.teams,drives.rewind,drives.account," +
"drives.quota" // TODO It should not be useful in prod, remove it if it works without in production
"drives.quota"

private const val noDefaultAvatar = "no_avatar_default=1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,12 @@ open class Drive(
val role: DriveUser.Role?
get() = enumValueOfOrNull<DriveUser.Role>(_role)

// Old offer pack, now replaced by My kSuite
inline val isFreePack get() = pack?.type == DrivePack.DrivePackType.FREE

// Old offer pack, now replaced by My kSuite Plus
inline val isSoloPack get() = pack?.type == DrivePack.DrivePackType.SOLO

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 isTechnicalMaintenance get() = maintenanceReason == MaintenanceReason.TECHNICAL.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class TrashFragment : FileSubTypeListFragment() {
}

private fun setupAutoClearUpgradeLayout() {
binding.trashAutoClearLayout.isVisible = AccountUtils.getCurrentDrive()?.isMyKSuitePack == true
binding.trashAutoClearLayout.isVisible = AccountUtils.getCurrentDrive()?.isFreeTier == true
binding.trashAutoClearUpgradeButton.setOnClickListener {
findNavController().openMyKSuiteUpgradeBottomSheet(KSuiteApp.Drive)
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/infomaniak/drive/utils/AccountUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ object AccountUtils : CredentialManager() {

fun getAllUsersSync(): List<User> = userDatabase.userDao().getAllSync()

fun refreshCurrentDrive() {
currentDrive = DriveInfosController.getDrive(currentUserId, currentDriveId, maintenance = false) ?: getFirstDrive()
}

fun getCurrentDrive(forceRefresh: Boolean = false): Drive? {
if (currentDriveId != currentDrive?.id || forceRefresh) refreshCurrentDrive()
return currentDrive
}

private fun refreshCurrentDrive() {
currentDrive = DriveInfosController.getDrive(currentUserId, currentDriveId, maintenance = false) ?: getFirstDrive()
}

private fun getFirstDrive(): Drive? {
val currentDrive = DriveInfosController.getDrive(currentUserId, sharedWithMe = false, maintenance = false)
currentDrive?.let { currentDriveId = it.id }
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_file_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@

<TextView
android:id="@+id/trashAutoClearDescription"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marginStandardMedium"
android:text="@string/trashAutoClearDescription"
app:layout_constraintBottom_toTopOf="@id/trashAutoClearUpgradeButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/trashAutoClearIcon"
app:layout_constraintTop_toTopOf="parent" />

Expand All @@ -129,10 +130,10 @@
<com.infomaniak.core.myksuite.ui.views.MyKSuitePlusChipView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundColor="@color/myKSuiteChipOnBackground"
app:layout_constraintBottom_toBottomOf="@id/trashAutoClearUpgradeButton"
app:layout_constraintStart_toEndOf="@id/trashAutoClearUpgradeButton"
app:layout_constraintTop_toTopOf="@id/trashAutoClearUpgradeButton"
app:backgroundColor="@color/myKSuiteChipOnBackground" />
app:layout_constraintTop_toTopOf="@id/trashAutoClearUpgradeButton" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/layout/fragment_file_share_link_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginStandardMedium"
android:layout_marginBottom="@dimen/marginStandardSmall"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/marginStandard"
android:paddingBottom="@dimen/marginStandardSmall">
android:paddingBottom="@dimen/marginStandardMedium">

<TextView
android:id="@+id/addPasswordTitle"
Expand Down Expand Up @@ -170,10 +169,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marginStandardSmall"
android:visibility="gone"
app:backgroundColor="@color/myKSuiteChipOnCardBackground"
app:layout_constraintBottom_toBottomOf="@id/upgradeOfferPassword"
app:layout_constraintStart_toEndOf="@id/upgradeOfferPassword"
app:layout_constraintTop_toTopOf="@id/upgradeOfferPassword"
app:backgroundColor="@color/myKSuiteChipOnCardBackground"
tools:visibility="visible" />

<com.infomaniak.lib.core.views.EndIconTextInputLayout
Expand Down Expand Up @@ -253,10 +252,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/marginStandardMedium"
android:layout_marginBottom="@dimen/marginStandardSmall"
android:background="?selectableItemBackground"
android:paddingHorizontal="@dimen/marginStandard"
android:paddingBottom="@dimen/marginStandardSmall">
android:paddingBottom="@dimen/marginStandardMedium">

<TextView
android:id="@+id/addExpirationDateTitle"
Expand Down Expand Up @@ -304,10 +302,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/marginStandardSmall"
android:visibility="gone"
app:backgroundColor="@color/myKSuiteChipOnCardBackground"
app:layout_constraintBottom_toBottomOf="@id/upgradeOfferExpirationDate"
app:layout_constraintStart_toEndOf="@id/upgradeOfferExpirationDate"
app:layout_constraintTop_toTopOf="@id/upgradeOfferExpirationDate"
app:backgroundColor="@color/myKSuiteChipOnCardBackground"
tools:visibility="visible" />

<com.infomaniak.drive.views.DateInputView
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_new_folder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@
<TextView
android:id="@+id/dropBoxTitle"
style="@style/Subtitle2"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandardMedium"
android:text="@string/dropBoxTitle"
app:layout_constraintBottom_toBottomOf="@id/dropBoxIcon"
app:layout_constraintEnd_toStartOf="@id/myKSuitePlusChip"
app:layout_constraintStart_toEndOf="@id/dropBoxIcon"
app:layout_constraintTop_toTopOf="@id/dropBoxIcon" />

Expand All @@ -190,10 +191,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/marginStandardMedium"
app:backgroundColor="@color/myKSuiteChipOnCardBackground"
app:layout_constraintBottom_toBottomOf="@+id/dropBoxTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/dropBoxTitle"
app:backgroundColor="@color/myKSuiteChipOnCardBackground" />
app:layout_constraintTop_toTopOf="@id/dropBoxTitle" />

<TextView
android:id="@+id/dropBoxDescription"
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/res/navigation/main_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,18 +1051,4 @@
app:destination="@id/fileListFragment" />
</fragment>

<fragment
android:id="@+id/myKSuiteDashboardFragment"
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteDashboardFragment"
android:label="MyKSuiteDashboardFragment">
<argument
android:name="userName"
app:argType="string" />
<argument
android:name="avatarUri"
app:argType="string" />
<argument
android:name="dailySendLimit"
app:argType="string" />
</fragment>
</navigation>

0 comments on commit ad604cf

Please sign in to comment.