Some RTL Fixes

This commit is contained in:
TheBrokenRail 2024-02-18 04:09:58 -05:00
parent 5d49c8104b
commit 6b8b0af8cd
3 changed files with 11 additions and 24 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
/.idea/workspace.xml /.idea/workspace.xml
/.idea/navEditor.xml /.idea/navEditor.xml
/.idea/assetWizardSettings.xml /.idea/assetWizardSettings.xml
/.idea/deploymentTargetDropDown.xml
.DS_Store .DS_Store
/build /build
/captures /captures

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<State>
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="R5CRB1GE0RY" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-02-18T08:17:36.558261831Z" />
</State>
</entry>
</value>
</component>
</project>

View File

@ -72,7 +72,15 @@ public class CategoryView extends FrameLayout {
* @param onClickItem Callback when clicking on an item * @param onClickItem Callback when clicking on an item
*/ */
public <T extends Category.Named> void setup(Category<T> category, Runnable onClickTitle, Consumer<T> onClickItem) { public <T extends Category.Named> void setup(Category<T> category, Runnable onClickTitle, Consumer<T> 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); title.setText(titleText);
card.setVisibility(category.isOpen ? VISIBLE : GONE); card.setVisibility(category.isOpen ? VISIBLE : GONE);
title.setOnClickListener(v -> onClickTitle.run()); title.setOnClickListener(v -> onClickTitle.run());
@ -113,6 +121,7 @@ public class CategoryView extends FrameLayout {
getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.selectableItemBackground, outValue, true); getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.selectableItemBackground, outValue, true);
item.setBackgroundResource(outValue.resourceId); item.setBackgroundResource(outValue.resourceId);
// Layout // Layout
item.setTextAlignment(TEXT_ALIGNMENT_VIEW_START);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
item.setLayoutParams(layoutParams); item.setLayoutParams(layoutParams);
// Add To View // Add To View