From 1ac919b8d32c5b4f3038928b0e0365e4b367e132 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 22 Apr 2021 14:12:49 +0300 Subject: [PATCH] RTL: fix Live Updates screen --- OsmAnd/res/drawable/rectangle_rounded_left.xml | 7 +++++++ OsmAnd/res/drawable/ripple_rectangle_rounded_left.xml | 11 +++++++++++ OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java | 3 +++ .../osmand/plus/liveupdates/LiveUpdatesFragment.java | 8 ++++---- .../bottomsheets/BooleanPreferenceBottomSheet.java | 8 +++++--- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 OsmAnd/res/drawable/rectangle_rounded_left.xml create mode 100644 OsmAnd/res/drawable/ripple_rectangle_rounded_left.xml diff --git a/OsmAnd/res/drawable/rectangle_rounded_left.xml b/OsmAnd/res/drawable/rectangle_rounded_left.xml new file mode 100644 index 0000000000..56b3235c6c --- /dev/null +++ b/OsmAnd/res/drawable/rectangle_rounded_left.xml @@ -0,0 +1,7 @@ + + + + diff --git a/OsmAnd/res/drawable/ripple_rectangle_rounded_left.xml b/OsmAnd/res/drawable/ripple_rectangle_rounded_left.xml new file mode 100644 index 0000000000..c63df94daf --- /dev/null +++ b/OsmAnd/res/drawable/ripple_rectangle_rounded_left.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 5fdea403d3..8b3fc01882 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -445,6 +445,9 @@ public class ContextMenuAdapter { ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon); imageView.setImageDrawable(drawable); imageView.setVisibility(View.VISIBLE); + if (secondaryDrawable == R.drawable.ic_action_additional_option) { + UiUtilities.rotateImageByLayoutDirection(imageView); + } } else { ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon); if (imageView != null) { diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index c4fa160e08..7bebeda1f2 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -275,16 +275,14 @@ public class LiveUpdatesFragment extends BaseOsmAndDialogFragment implements OnL TextViewEx toolbarTitle = (TextViewEx) toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setText(R.string.osm_live); - View closeButton = toolbar.findViewById(R.id.close_button); + ImageView closeButton = (ImageView) toolbar.findViewById(R.id.close_button); + UiUtilities.rotateImageByLayoutDirection(closeButton); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); - if (closeButton instanceof ImageView) { - UiUtilities.rotateImageByLayoutDirection((ImageView) closeButton); - } FrameLayout iconHelpContainer = toolbar.findViewById(R.id.action_button); int iconColorResId = nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light; @@ -443,6 +441,8 @@ public class LiveUpdatesFragment extends BaseOsmAndDialogFragment implements OnL boolean isLastChild, View convertView, ViewGroup parent) { LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); convertView = inflater.inflate(R.layout.list_item_triple_row_icon_and_menu, parent, false); + ImageView secondaryIcon = (ImageView) convertView.findViewById(R.id.secondary_icon); + UiUtilities.rotateImageByLayoutDirection(secondaryIcon); LiveMapsViewHolder viewHolder = new LiveMapsViewHolder(convertView); convertView.setTag(viewHolder); viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition).getFileName()); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index 858e32c962..1fd19e00c1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -134,6 +134,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { public static void updateCustomButtonView(OsmandApplication app, ApplicationMode mode, View customView, boolean checked, boolean nightMode) { Context themedCtx = UiUtilities.getThemedContext(app, nightMode); + boolean isLayoutRtl = AndroidUtils.isLayoutRtl(themedCtx); LinearLayout buttonView = customView.findViewById(R.id.button_container); int bgColor; @@ -149,10 +150,11 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { ContextCompat.getColor(app, getActivePrimaryColorId(nightMode)), checked ? 0.3f : 0.5f); } - int bgResId = R.drawable.rectangle_rounded_right; + int bgResId = isLayoutRtl ? R.drawable.rectangle_rounded_left : R.drawable.rectangle_rounded_right; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { - int selectableResId = R.drawable.ripple_rectangle_rounded_right; - + int selectableResId = isLayoutRtl ? + R.drawable.ripple_rectangle_rounded_left : + R.drawable.ripple_rectangle_rounded_right; Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor); Drawable selectable = app.getUIUtilities().getPaintedIcon(selectableResId, selectedColor); Drawable[] layers = {bgDrawable, selectable};