Skip to content

Commit

Permalink
Feature - RTL Support
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin41500 committed Aug 7, 2018
1 parent 37b39ca commit cf3cdd0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public CalendarPagerView(
setClipChildren(false);
setClipToPadding(false);

if (LocalUtils.isRTL()) {
this.setRotationY(180);
}

if (showWeekDays) {
buildWeekDays(resetAndGetWorkingCalendar());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.prolificinteractive.materialcalendarview;

import android.support.v4.text.TextUtilsCompat;
import android.support.v4.view.ViewCompat;
import java.util.Locale;

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;
}
}
11 changes: 11 additions & 0 deletions library/src/main/res/drawable-ldrtl/mcv_action_next.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp"
>
<path
android:fillColor="#000000"
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"
/>
</vector>
11 changes: 11 additions & 0 deletions library/src/main/res/drawable-ldrtl/mcv_action_previous.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp"
>
<path
android:fillColor="#000000"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"
/>
</vector>
4 changes: 2 additions & 2 deletions library/src/main/res/layout/calendar_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/previous"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_previous"
app:srcCompat="@drawable/mcv_action_next"
/>

<TextView
Expand All @@ -39,7 +39,7 @@
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/next"
android:padding="@dimen/mcv_arrow_padding"
app:srcCompat="@drawable/mcv_action_next"
app:srcCompat="@drawable/mcv_action_previous"
/>

</LinearLayout>

0 comments on commit cf3cdd0

Please sign in to comment.