From 2be03d04ed8fbfafab2e15dd873bcb55ed90e690 Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 19 Apr 2021 16:35:26 +0500 Subject: [PATCH] Purchases screen RTL fixes --- OsmAnd/res/layout/subscription_layout.xml | 1 - OsmAnd/res/layout/troubleshooting_card.xml | 1 - OsmAnd/src/net/osmand/plus/UiUtilities.java | 7 +++---- .../src/net/osmand/plus/activities/PluginInfoFragment.java | 2 +- OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java | 2 +- .../plus/settings/fragments/BaseSettingsFragment.java | 2 +- .../osmand/plus/settings/fragments/PurchasesFragment.java | 1 + .../fragments/TroubleshootingOrPurchasingCard.java | 5 +++++ 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/layout/subscription_layout.xml b/OsmAnd/res/layout/subscription_layout.xml index 411e49db31..044ab6ba03 100644 --- a/OsmAnd/res/layout/subscription_layout.xml +++ b/OsmAnd/res/layout/subscription_layout.xml @@ -64,7 +64,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/content_padding_small" - android:layout_gravity="center_vertical" android:paddingStart="@dimen/content_padding_small" android:paddingLeft="@dimen/content_padding_small" android:paddingTop="@dimen/content_padding_small_half" diff --git a/OsmAnd/res/layout/troubleshooting_card.xml b/OsmAnd/res/layout/troubleshooting_card.xml index e7de139dc1..3ce447d5d0 100644 --- a/OsmAnd/res/layout/troubleshooting_card.xml +++ b/OsmAnd/res/layout/troubleshooting_card.xml @@ -32,7 +32,6 @@ android:id="@+id/troubleshooting_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/map_widget_height" android:layout_marginRight="@dimen/map_widget_height" android:paddingBottom="@dimen/dialog_content_bottom_margin" diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index a7c0223c22..886b1c7f8c 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -442,15 +442,14 @@ public class UiUtilities { } catch (Throwable e) { } } - public static void rotateImageByLayoutDirection(ImageView image, int layoutDirection) { - if (image == null) { + public static void rotateImageByLayoutDirection(ImageView image, Context context) { + if (image == null || context == null) { return; } - int rotation = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL ? 180 : 0; + int rotation = AndroidUtils.getLayoutDirection(context) == ViewCompat.LAYOUT_DIRECTION_RTL ? 180 : 0; image.setRotationY(rotation); } - public static void updateCustomRadioButtons(Context app, View buttonsView, boolean nightMode, CustomRadioButtonType buttonType) { int activeColor = ContextCompat.getColor(app, nightMode diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java index ced666e32b..90fccc5c3e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java @@ -109,7 +109,7 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat } } }); - UiUtilities.rotateImageByLayoutDirection(closeButton, AndroidUtils.getLayoutDirection(app)); + UiUtilities.rotateImageByLayoutDirection(closeButton, app); Drawable pluginImage = plugin.getAssetResourceImage(); if (pluginImage != null) { diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java index 04666e9607..5b6c302d84 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginsFragment.java @@ -101,7 +101,7 @@ public class PluginsFragment extends BaseOsmAndFragment implements PluginStateLi } } }); - UiUtilities.rotateImageByLayoutDirection(closeButton, AndroidUtils.getLayoutDirection(app)); + UiUtilities.rotateImageByLayoutDirection(closeButton, app); adapter = new PluginsListAdapter(requireContext()); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index 05c4c7e323..f89afd91a2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -493,7 +493,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl }); if (closeButton instanceof ImageView) { UiUtilities.rotateImageByLayoutDirection( - (ImageView) closeButton, AndroidUtils.getLayoutDirection(app)); + (ImageView) closeButton, app); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java index 461f51e14d..8cd4d61179 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/PurchasesFragment.java @@ -152,6 +152,7 @@ public class PurchasesFragment extends BaseOsmAndFragment implements InAppPurcha } }); ImageButton backButton = toolbar.findViewById(R.id.close_button); + UiUtilities.rotateImageByLayoutDirection(backButton, getContext()); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java index f0ed9d8968..db33837202 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/TroubleshootingOrPurchasingCard.java @@ -7,10 +7,12 @@ import android.text.Spannable; import android.text.SpannableString; import android.text.style.StyleSpan; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.inapp.InAppPurchaseHelper; @@ -74,6 +76,9 @@ public class TroubleshootingOrPurchasingCard extends BaseCard { } else { AndroidUtils.setBackground(mapActivity, getItButton, nightMode, R.drawable.btn_unstroked_light, R.drawable.btn_unstroked_dark); } + + ImageView getItArrow = view.findViewById(R.id.additional_button_icon); + UiUtilities.rotateImageByLayoutDirection(getItArrow, app); } }