From a4f920e4227a7f3c910dd9dc1c75073e09483734 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Mon, 4 Mar 2024 13:29:34 +0100 Subject: [PATCH 1/3] Modify switch account button so it doesn't overlap with search menu in RootFilesFragment The text below the transparent button needs to still be displayed the exact same way, so we overlay a transparent button to reduce its size independently. By limiting its size we prevent wide switch drive buttons from overlapping with the search menu from the toolbar in RootFilesFragment blocking some clicks that were aimed at the search menu button --- .../com/infomaniak/drive/utils/Extensions.kt | 10 ++-- .../main/res/layout/layout_switch_drive.xml | 53 +++++++++++++++++-- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt b/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt index 97cd698536..23f376c8c5 100644 --- a/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt +++ b/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt @@ -405,15 +405,15 @@ fun LayoutSwitchDriveBinding.setDriveHeader(currentDrive: Drive) { } fun LayoutSwitchDriveBinding.setupSwitchDriveButton(fragment: Fragment) { - switchDriveButton.apply { - AccountUtils.getCurrentDrive()?.let { setDriveHeader(it) } + AccountUtils.getCurrentDrive()?.let { setDriveHeader(it) } - if (DriveInfosController.hasSingleDrive(AccountUtils.currentUserId)) { + if (DriveInfosController.hasSingleDrive(AccountUtils.currentUserId)) { + switchDriveButton.apply { icon = null isEnabled = false - } else { - setOnClickListener { fragment.safeNavigate(R.id.switchDriveDialog) } } + } else { + offsetOverlayedRipple.setOnClickListener { fragment.safeNavigate(R.id.switchDriveDialog) } } fragment.viewLifecycleOwner.lifecycle.addObserver( diff --git a/app/src/main/res/layout/layout_switch_drive.xml b/app/src/main/res/layout/layout_switch_drive.xml index 034ed397e4..0930ec9ae5 100644 --- a/app/src/main/res/layout/layout_switch_drive.xml +++ b/app/src/main/res/layout/layout_switch_drive.xml @@ -15,12 +15,13 @@ ~ You should have received a copy of the GNU General Public License ~ along with this program. If not, see . --> - @@ -30,8 +31,7 @@ style="@style/TextButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginEnd="@dimen/marginStandard" + android:clickable="false" android:contentDescription="@string/buttonSwitchDrive" android:ellipsize="end" android:fontFamily="@font/suisseintl_bold" @@ -45,6 +45,49 @@ app:iconGravity="end" app:iconSize="28dp" app:iconTint="@color/iconColor" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0" + app:layout_constraintStart_toStartOf="parent" tools:text="Drive de test dev infomaniak" /> - + + + + + + + + + + From 19a2db01778bbdf58c0d63b22f2b8bc4ec32d1d6 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 6 Mar 2024 08:20:14 +0100 Subject: [PATCH 2/3] Simplify code --- .../java/com/infomaniak/drive/utils/Extensions.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt b/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt index 23f376c8c5..94f76ac3e3 100644 --- a/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt +++ b/app/src/main/java/com/infomaniak/drive/utils/Extensions.kt @@ -30,10 +30,7 @@ import android.os.Build.VERSION import android.os.Build.VERSION_CODES import android.provider.MediaStore import android.text.format.Formatter -import android.transition.AutoTransition -import android.transition.TransitionManager -import android.transition.TransitionSet -import android.util.DisplayMetrics +import android.transition.* import android.util.Patterns import android.view.ViewGroup import android.view.animation.Animation @@ -46,7 +43,7 @@ import androidx.core.view.children import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.Fragment -import androidx.lifecycle.Lifecycle +import androidx.lifecycle.Lifecycle.* import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData @@ -405,7 +402,8 @@ fun LayoutSwitchDriveBinding.setDriveHeader(currentDrive: Drive) { } fun LayoutSwitchDriveBinding.setupSwitchDriveButton(fragment: Fragment) { - AccountUtils.getCurrentDrive()?.let { setDriveHeader(it) } + + AccountUtils.getCurrentDrive()?.let(::setDriveHeader) if (DriveInfosController.hasSingleDrive(AccountUtils.currentUserId)) { switchDriveButton.apply { @@ -418,8 +416,8 @@ fun LayoutSwitchDriveBinding.setupSwitchDriveButton(fragment: Fragment) { fragment.viewLifecycleOwner.lifecycle.addObserver( object : LifecycleEventObserver { - override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { - if (event == Lifecycle.Event.ON_RESUME) AccountUtils.getCurrentDrive()?.let { setDriveHeader(it) } + override fun onStateChanged(source: LifecycleOwner, event: Event) { + if (event == Event.ON_RESUME) AccountUtils.getCurrentDrive()?.let(::setDriveHeader) } }, ) From 1c6d807f48725cd5d83cb9e53cc35e0604030091 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 20 Mar 2024 07:26:31 +0100 Subject: [PATCH 3/3] Update comment --- app/src/main/res/layout/layout_switch_drive.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/layout_switch_drive.xml b/app/src/main/res/layout/layout_switch_drive.xml index 0930ec9ae5..e1986dd05a 100644 --- a/app/src/main/res/layout/layout_switch_drive.xml +++ b/app/src/main/res/layout/layout_switch_drive.xml @@ -51,8 +51,8 @@ app:layout_constraintStart_toStartOf="parent" tools:text="Drive de test dev infomaniak" /> - +