From 6b8b0af8cdb5580f52e54ff99d61d3c13f74474d Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 18 Feb 2024 04:09:58 -0500 Subject: [PATCH] Some RTL Fixes --- .gitignore | 1 + .idea/deploymentTargetDropDown.xml | 23 ------------------- .../mtudining/widget/CategoryView.java | 11 ++++++++- 3 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.gitignore b/.gitignore index b2dc3af..9fba514 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml +/.idea/deploymentTargetDropDown.xml .DS_Store /build /captures diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 58aad1d..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/thebrokenrail/mtudining/widget/CategoryView.java b/app/src/main/java/com/thebrokenrail/mtudining/widget/CategoryView.java index 85a2d0d..ff697af 100644 --- a/app/src/main/java/com/thebrokenrail/mtudining/widget/CategoryView.java +++ b/app/src/main/java/com/thebrokenrail/mtudining/widget/CategoryView.java @@ -72,7 +72,15 @@ public class CategoryView extends FrameLayout { * @param onClickItem Callback when clicking on an item */ public void setup(Category category, Runnable onClickTitle, Consumer onClickItem) { - String titleText = (category.isOpen ? "▼" : "▶") + " " + category.name; + String icon = category.isOpen ? "▼" : "▶"; + String titleText = category.name; + if (getResources().getConfiguration().getLayoutDirection() == LAYOUT_DIRECTION_RTL) { + // RTL + titleText += " " + icon; + } else { + // LTR + titleText = icon + " " + titleText; + } title.setText(titleText); card.setVisibility(category.isOpen ? VISIBLE : GONE); title.setOnClickListener(v -> onClickTitle.run()); @@ -113,6 +121,7 @@ public class CategoryView extends FrameLayout { getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.selectableItemBackground, outValue, true); item.setBackgroundResource(outValue.resourceId); // Layout + item.setTextAlignment(TEXT_ALIGNMENT_VIEW_START); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); item.setLayoutParams(layoutParams); // Add To View