From 255598769905a7f86ecfb6315937a68a7f191c81 Mon Sep 17 00:00:00 2001 From: Quentin Colle Date: Sat, 11 Aug 2018 17:26:42 -0400 Subject: [PATCH] Feature - RTL Support (#844) --- .../materialcalendarview/CalendarPagerView.java | 4 ---- .../materialcalendarview/LocalUtils.java | 11 ++++------- .../src/main/res/drawable-ldrtl/mcv_action_next.xml | 11 +++++++++++ .../main/res/drawable-ldrtl/mcv_action_previous.xml | 11 +++++++++++ 4 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 library/src/main/res/drawable-ldrtl/mcv_action_next.xml create mode 100644 library/src/main/res/drawable-ldrtl/mcv_action_previous.xml diff --git a/library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java b/library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java index 5be5b005..f3a4fa9a 100644 --- a/library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java +++ b/library/src/main/java/com/prolificinteractive/materialcalendarview/CalendarPagerView.java @@ -55,10 +55,6 @@ public CalendarPagerView( setClipChildren(false); setClipToPadding(false); - if (LocalUtils.isRTL()) { - this.setRotationY(180); - } - if (showWeekDays) { buildWeekDays(resetAndGetWorkingCalendar()); } diff --git a/library/src/main/java/com/prolificinteractive/materialcalendarview/LocalUtils.java b/library/src/main/java/com/prolificinteractive/materialcalendarview/LocalUtils.java index e9f1ddc8..19870623 100644 --- a/library/src/main/java/com/prolificinteractive/materialcalendarview/LocalUtils.java +++ b/library/src/main/java/com/prolificinteractive/materialcalendarview/LocalUtils.java @@ -1,5 +1,7 @@ package com.prolificinteractive.materialcalendarview; +import android.support.v4.text.TextUtilsCompat; +import android.support.v4.view.ViewCompat; import java.util.Locale; class LocalUtils { @@ -7,12 +9,7 @@ class LocalUtils { private LocalUtils() { } static boolean isRTL() { - return isRTL(Locale.getDefault()); - } - - private static boolean isRTL(Locale locale) { - final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0)); - return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT || - directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; + return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) + == ViewCompat.LAYOUT_DIRECTION_RTL; } } diff --git a/library/src/main/res/drawable-ldrtl/mcv_action_next.xml b/library/src/main/res/drawable-ldrtl/mcv_action_next.xml new file mode 100644 index 00000000..0b624e03 --- /dev/null +++ b/library/src/main/res/drawable-ldrtl/mcv_action_next.xml @@ -0,0 +1,11 @@ + + + diff --git a/library/src/main/res/drawable-ldrtl/mcv_action_previous.xml b/library/src/main/res/drawable-ldrtl/mcv_action_previous.xml new file mode 100644 index 00000000..9080087f --- /dev/null +++ b/library/src/main/res/drawable-ldrtl/mcv_action_previous.xml @@ -0,0 +1,11 @@ + + +