From a8355f609b0ff8952f9a25aa59372f6095fd17db Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Sun, 11 Jun 2023 23:09:47 +0200 Subject: [PATCH 1/2] LoyaltyCardViewActivity: RTL fixes for buttons --- .../card_locker/LoyaltyCardViewActivity.java | 27 +++++++++++++------ .../res/layout/loyalty_card_view_layout.xml | 8 +++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 4327f4022..dad65ca3e 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -984,22 +984,33 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements return; } + final ImageButton prevButton; + final ImageButton nextButton; + + if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { + prevButton = binding.mainRightButton; + nextButton = binding.mainLeftButton; + } else { + prevButton = binding.mainLeftButton; + nextButton = binding.mainRightButton; + } + // Enable left button if we can go further left if (mainImageIndex > 0) { - binding.mainLeftButton.setVisibility(View.VISIBLE); - binding.mainLeftButton.setOnClickListener(view -> setMainImage(false, false)); + prevButton.setVisibility(View.VISIBLE); + prevButton.setOnClickListener(view -> setMainImage(false, false)); } else { - binding.mainLeftButton.setVisibility(View.INVISIBLE); - binding.mainLeftButton.setOnClickListener(null); + prevButton.setVisibility(View.INVISIBLE); + prevButton.setOnClickListener(null); } // Enable right button if we can go further right if (mainImageIndex < (imageTypes.size() - 1)) { - binding.mainRightButton.setVisibility(View.VISIBLE); - binding.mainRightButton.setOnClickListener(view -> setMainImage(true, false)); + nextButton.setVisibility(View.VISIBLE); + nextButton.setOnClickListener(view -> setMainImage(true, false)); } else { - binding.mainRightButton.setVisibility(View.INVISIBLE); - binding.mainRightButton.setOnClickListener(null); + nextButton.setVisibility(View.INVISIBLE); + nextButton.setOnClickListener(null); } } diff --git a/app/src/main/res/layout/loyalty_card_view_layout.xml b/app/src/main/res/layout/loyalty_card_view_layout.xml index 887ab75d6..63b8e26f2 100644 --- a/app/src/main/res/layout/loyalty_card_view_layout.xml +++ b/app/src/main/res/layout/loyalty_card_view_layout.xml @@ -83,7 +83,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginStart="0dp" - android:layout_marginEnd="0dp"> + android:layout_marginEnd="0dp" + android:layoutDirection="ltr"> Date: Mon, 12 Jun 2023 15:26:21 +0200 Subject: [PATCH 2/2] improve button bar RTL handling using linear layouts --- .../res/layout/loyalty_card_view_layout.xml | 104 ++++++++++-------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/app/src/main/res/layout/loyalty_card_view_layout.xml b/app/src/main/res/layout/loyalty_card_view_layout.xml index 63b8e26f2..22e300035 100644 --- a/app/src/main/res/layout/loyalty_card_view_layout.xml +++ b/app/src/main/res/layout/loyalty_card_view_layout.xml @@ -207,7 +207,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" - android:layoutDirection="ltr" android:background="?attr/colorPrimary" app:contentInsetLeft="0dp" app:contentInsetStart="0dp" @@ -215,53 +214,70 @@ app:contentInsetEnd="0dp" app:fabAlignmentMode="center"> - + android:layoutDirection="ltr"> - + - + - + + + + + + + + + + +