From 1ac919b8d32c5b4f3038928b0e0365e4b367e132 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 22 Apr 2021 14:12:49 +0300 Subject: [PATCH 1/2] 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}; From 42604ac3b619d83c02c6bcf63241e02b4a9217af Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 22 Apr 2021 15:02:10 +0300 Subject: [PATCH 2/2] RTL: fix slider on Announcement Time dialog --- .../seekbar_progress_announcement_time.xml | 15 ---- .../seekbar_thumb_announcement_time.xml | 13 --- .../seekbar_tickmark_announcement_time.xml | 8 -- .../layout/bottom_sheet_announcement_time.xml | 14 +-- .../AnnouncementTimeBottomSheet.java | 86 ++++++------------- 5 files changed, 30 insertions(+), 106 deletions(-) delete mode 100644 OsmAnd/res/drawable/seekbar_progress_announcement_time.xml delete mode 100644 OsmAnd/res/drawable/seekbar_thumb_announcement_time.xml delete mode 100644 OsmAnd/res/drawable/seekbar_tickmark_announcement_time.xml diff --git a/OsmAnd/res/drawable/seekbar_progress_announcement_time.xml b/OsmAnd/res/drawable/seekbar_progress_announcement_time.xml deleted file mode 100644 index 794539923e..0000000000 --- a/OsmAnd/res/drawable/seekbar_progress_announcement_time.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/seekbar_thumb_announcement_time.xml b/OsmAnd/res/drawable/seekbar_thumb_announcement_time.xml deleted file mode 100644 index a126aee222..0000000000 --- a/OsmAnd/res/drawable/seekbar_thumb_announcement_time.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/seekbar_tickmark_announcement_time.xml b/OsmAnd/res/drawable/seekbar_tickmark_announcement_time.xml deleted file mode 100644 index d6662da81f..0000000000 --- a/OsmAnd/res/drawable/seekbar_tickmark_announcement_time.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_announcement_time.xml b/OsmAnd/res/layout/bottom_sheet_announcement_time.xml index 246ffe3476..308ad0278a 100644 --- a/OsmAnd/res/layout/bottom_sheet_announcement_time.xml +++ b/OsmAnd/res/layout/bottom_sheet_announcement_time.xml @@ -62,18 +62,12 @@ osmand:typeface="@string/font_roboto_medium" tools:text="Normal" /> - + android:layout_marginLeft="@dimen/content_padding" + android:layout_marginRight="@dimen/content_padding" />